Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
145
WInGrid add item to bound valuelist
posted

What event to I need to handle to allow users to add "fruit" the either a valuelist or ultra dropdown.

Since it is a KVP I always get format exception

//Create some fruit
Dictionary<int,string> fruits = new Dictionary<int,string>();
fruits
.Add(-1,"apple");
fruits
.Add(-2,"banana");

//Create and add to the ultraDropDown
UltraDropDown fruitUltraDropDown = new UltraDropDown();
fruitUltraDropDown
.DataSource = fruits.ToList();
fruitUltraDropDown
.DisplayMember = "Value";
fruitUltraDropDown
.ValueMember = "Key";
MyUltraGrid.DisplayLayout.Bands[0].Columns["MyColumn"].ValueList = fruitUltraDropDown;

What event can I handle so when a user types "grape" I can add it to the dictionary with my own key, and it gets added to the dropdownlist. Currently if I type "grape in the cell, I just get a format exception.

Regards

_Eric

Parents
  • 469350
    Offline posted

    Hi Eric,

    There are a number of events you could use. I would probably use BeforeCellUpdate or maybe BeforeExitEditMode.

    Either way, what you would do is use the ValueListResolved property on the cell to get the ValueList and then you can use the GetValue method to try to find a matching item on the list. Use the cell.EditorResolved.Text to get the current edit text in the cell for your search.

     

Reply Children