My current application takes a number and converts it to text values from another table. I create a ultradropdown and then filter the values on the row initialize event. The field is bound to a decimal column in the database. The dropdowns that contain text convert back to numbers, display value = "Red" value = 20001. Everything works great.
Now I have a requirement to add the ability to enter text into the column instead of numbers. Instead of trying to do convolutions to change the datatype I simply created an unbound column and set the valuelist to exactly the same dropdown as the bound column.
For some reason the dropdown is not converting the display value correctly. It just shows the system numbers instead of the text set in the valuelist.
Attached is a screen shot. The first column with the 200001 value should actually be saying Red.
Hi,
You kinda lost me a little bit here. You are assigning an UltraDropDown to the column and then filtering it in InitializeRow? Why filter the list? And why do it in InitializeRow. That doesn't seem like a good event to use, since it will essentially filter the list based on the last row which was initialized and that's completely arbitrary.
The System Code table holds many different values for different types of data and depending on other data on the row it should filter the list for different values. So if the line is concerning Color the grid will filter the list to only show system codes that are related to color and the user can then choose a color they want. Where it gets tricky if the row data says that it is not a system code list then I change the cell to a text editor and they are able to type in a number.
You are correct in wondering why I filter on initialize row and I will remove that code because I am also using the beforecellclick event to filter it yet again so that it shows the correct values for the user. Filtering it in the initialize row is redundant.
I stil have the issue where an unbound row that is prepared exactly the same as a bound row doesn't show the display value by default but instead shows the underlying data value.
case 2004://Systemcode liste.Row.Cells["ValueEntry"].ValueList = uddSystemCodeValues;e.Row.Cells["ValueEntry"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;e.Row.Cells["ValueEntry"].Activation = Activation.AllowEdit; e.Row.Cells["Value"].ValueList = uddSystemCodeValues;e.Row.Cells["Value"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;e.Row.Cells["Value"].Activation = Activation.AllowEdit;
e.Row.Cells["ValueEntry"].SetValue(e.Row.Cells["Value"].Value, false);
In the code above you can see that I'm doing exactly the same thing to both the new column and the bound column.
Thinking a bit about it, the columns are different... is there a way to create a copy of a bound column and unbind it and change the key?
Currently all I do is create a simple unbound column
if (!ugResults.DisplayLayout.Bands[0].Columns.Exists("ValueEntry")){ugResults.DisplayLayout.Bands[0].Columns.Add("ValueEntry", "ValueEntry");}
Ok, I figured it out... if I set the datatype of the unbound column to integer and remove the text functionality then the new column I created shows the correct value in the field... BUT I can't enter text into the field because it's now an int column.
I'm thinking that when I fill the system code list I should change the datatype of the column to string instead of integer. Then when they enter the values in and I copy them into the table it will convert them back to numbers.
Am I crazy or is there an easier way to do this?
I think this is what you are looking for:
Creating a dropdown list in a grid cell whose list values are dependent on another cell - Windows Forms - Infragistics Community
I got it working. It' doesn't look like the the nicest implementation but it seems to work. A peice of information that I neglected to tell you but I don't think it matters. The Text value that the user can enter isn't stored in this table. The ID of the newly created text record is stored in this table and when it runs initialize row the ID is converted over to text by looking in a lookup table and then put into the unbound column.
So the reason was indeed the datatype. I converted the column datatype to string but it still didn't work. Then I created a new dropdown, created a new table datasource which was a clone of the original and changed the ID datatype to string. Then I copied all the values from the codes table into this newly cloned table. That's when I figured out that the .Value property was 200001 BUT the .Value.ToString() value was "200001.00000". So after a quick String.Remove the ultradropdowns are showing the displayvalues properly as you can see in the screen shot.