Hello Mike!I despair when trying to get a class as a response from the ultra drop down and use it as a value in my ultra grid cell! Can you please take a look at the following Code:(Hope you understand what I mean and I hope you can help me!)
private void ultraButton3_Click(object sender, EventArgs e) { // Data Source: DataTable dt = new DataTable(); dt.Columns.Add("Textfield", typeof(string)); dt.Columns.Add("Person", typeof(Person)); dt.Rows.Add(new object[] { "1. Person: ", null }); dt.Rows.Add(new object[] { "2. Person: ", null }); dt.Rows.Add(new object[] { "3. Person: ", null }); this.ultraGrid1.DataSource = dt;
// Drop-Down Inhalt: UltraDropDown dropDown = new UltraDropDown(); dropDown.DataSource = new List<Person> { new Person() { FirstName = "Max", LastName = "Huber", Age = 15 }, new Person() { FirstName = "Hans", LastName = "Mair", Age = 20 }, new Person() { FirstName = "Bettina", LastName = "Steiner", Age = 25 } }; dropDown.DisplayMember = "LastName";
// Drop-Down: DefaultEditorOwnerSettings editorSettings = new DefaultEditorOwnerSettings(); editorSettings.ValueList = dropDown;
EditorWithCombo editorWithCombo = new EditorWithCombo(new DefaultEditorOwner(editorSettings)); this.ultraGrid1.DisplayLayout.Bands[0].Columns["Person"].Editor = editorWithCombo; }
public class Person{ public string FirstName { get; set; } public string LastName { get; set; } public int Age { get; set; }}
Hi,
What's the problem you are having with this code?
I see a couple of things here.
First, I don't think you need to set the Editor on the column. You are already setting the ValueList property, so setting Editor is redundant here. You do not need the DefaultEditorOwnerSetting, either.
While this code is unnecessary, I don't think it will cause any problems, either.
The only thing I can see here that might be an actual problem is that your Person class does not override the Equals method. Since it doesn't override Equals, what will happen here is that if you set the value of the grid cell to a Person instance and it's not the same instance that exists on the list, it won't match up. So this should be fine as long as your grid starts off with null and you only pick items from the list, but it could be a problem if the grid cell values change without using the dropdown.