Hello!I have troubles with a ultraDropDown in a UltraGridCell:(UltraGridCell: Style=DropDown, ValueList=ultraDropDown1)Please see PDF File:
Thanks for Help!myGilli
mygil said:I can't use: this.ultraGrid1.Rows [0]. Cells ["Column 0"]. ValueListResolved.GetValue(SelectedDropDownIndex) because i dont have: SelectedDropDownIndex! (Remember: I need the SelctedDropDownIndex's of each Rows in my UltraGrid)
Of course not. The point of calling GetValue is to GET the index of the item. It would not make sense to attempt to get the index if you already had it. :)
mygil said:Or do you meen:foreach (UltraGridRow row in ultraGrid1.Rows){ int iIndex = 0; row.Cells["Column 0"].ValueListResolved.GetValue(row.Cells["Column 0"].Text, ref iIndex); MessageBox.Show(this.ultraDropDown1.Rows[iIndex].Cells["Datum"].Text);}
Yes, that's what I meant.
mygil said:but then i have troubles with rows with same names
Yes, I can see that would be a problem. But I think we've come back around again to the question of exactly what you are trying to do here. If you are just trying to lookup other fields on the list then the cell in the grid is going to have to contain data that identifies a row in the dropdown in a unique way. So maybe you need to use GetText here instead of GetValue and pass in the cell's Value instead of the text. I am assuming, of course, that the values are unique and that you are using the Datum field as your ValueMember.
If the grid cell is storing strings and those strings are not unique, then what you are trying to do is not possible, anyway, since you will be losing what item the user selected from the list as soon as the user leaves the cell.
Hi Mike!I can't use: this.ultraGrid1.Rows [0]. Cells ["Column 0"]. ValueListResolved.GetValue(SelectedDropDownIndex) because i dont have: SelectedDropDownIndex! (Remember: I need the SelctedDropDownIndex's of each Rows in my UltraGrid)
Or do you meen:foreach (UltraGridRow row in ultraGrid1.Rows){ int iIndex = 0; row.Cells["Column 0"].ValueListResolved.GetValue(row.Cells["Column 0"].Text, ref iIndex); MessageBox.Show(this.ultraDropDown1.Rows[iIndex].Cells["Datum"].Text);}but then i have troubles with rows with same names like:I could live with this solution, but at the same time I would really regret if there is a better solution which I simply can’t find.Much thanks!
mygil said:1) lValueList interface methods? Do you meen the following:this.ultraGrid1.Rows [0]. Cells ["Column 0"]. ValueListResolved.GetValue(iIndex)For this solution I always need an index - if a have this index for each row so i can use it directly in the UltraDropDown: this.ultraDropDown1.Rows [iIndex]. Cells ["Model"]. Text
Yes, that is precisely what I meant.
mygil said:private void ultraGrid1_AfterCellListCloseUp(object sender, CellEventArgs e) { e.Cell.Tag = e.Cell.ValueListResolved.SelectedItemIndex; }
e)
{
e.Cell.Tag = e.Cell.ValueListResolved.SelectedItemIndex;
}
The problem with this code is that there are holes in it. The use can change the value of the cell (and thus the selected index) using the keyboard without ever dropping down the list. Also, depending on the Style property of the column, the user might type into the cell and the SelectedItemIndex on the list will not get updated.
Also, this code won't get called until the user makes a change to the cell. So the Tag of the cell will initially be blank when you load the grid for the first time - unless the user is changing every cell.
Personally, what I would do is use GetValue like you have it above. That way you are sure of getting the correct values from the list every time.
Hi Mike!
1) lValueList interface methods? Do you meen the following:this.ultraGrid1.Rows [0]. Cells ["Column 0"]. ValueListResolved.GetValue(iIndex)For this solution I always need an index - if a have this index for each row so i can use it directly in the UltraDropDown: this.ultraDropDown1.Rows [iIndex]. Cells ["Model"]. Text2) ValueMember+DisplayMember is not enoth - my real application need much more columns from a DropDown...
3) At the moment, i use this solution, what do you think about - do you know a better one?
ultraGrid1.Rows)
].Tag;
].Text);
Much thanks!
myGil
Using SelectedIndex would not be a reliably way to get the text, since the SelectedIndex depends on the current state of the dropdown. Even if this worked reliably, it would only ever work when the cell happens to be the ActiveCell.
It would be better to use the IValueList interface methods like GetText or GetValue. The UltraDropDown implements IValueList.
But what you do exactly depends on which field is your ValueMember and which one is your DisplayMember.
By the way... if you just want the grid to show the Model and not the HostName, then all you have to do is set those two properties, you don't need to get the text directly at all.