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
80
Assigning cell object values in UltraDropDown
posted

Hi, I'm having trouble assigning values of non-standard type (not integer, string, or whatever) to a cell with a UltraDropDown grid.

I'll try to explain

My grid (Let's call it Grid1)  is bound to a list of clsTypeA  "Grid1.DataSource =  New BindingList(of clsTypeA)" where:

public class clsTypeA

    public Id as Long

    public obj as clsTypeB

end class

Then I have an UltraDropDown (let's call it DropDown1) bound to a list of clsTypeB

public class clsTypeB

    public Id as Long

    public Description as string

    public overrides function ToString() as string

          return Me.Description

    end function

end class

In Grid1, the column "obj" ValueList property is set to DropDown1.

I enter the main grid Grid1 in edit mode, add a new row... go to the cell for the value of "obj", open the dropdown and the list of objects is there. Then I select any of the objects, but the grid, instead assigning the object I selected to the property "obj" in the row, it assigns the string of "Description", so when I try to update the row I get an error "Cannot convert string to clsTypeB".

Why is it assigning a string value when the DataSource for the UltraDropDown is of clsTypeB and the value type for the column is also clsTypeB and not string?? Do I have to change any special property? what would be the way to accomplish what I'm trying to do?

I've tried also to set the Style property of the column to "DropDownList" to avoid editing (that's another problem) but then even if I select an object in DropDown1, no value is assigned to the cell...

I don't know if I explained myself very wel...

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    The UltraDropDown is a multi-column dropdown. It's designed to let you pick a COLUMN in the dropdown that is associated with the cell in the grid. So when you select a row in the dropdown, it will, by default, take the value from the first column in the dropdown and try to put it into the grid cell. It's doesn't take the entire object representing the row and put that object in the cell.

    But you can do this in a couple of ways.

    1) Use the InitializeLayout event to add an unbound column to your UltraDropDown. Then, in the InitializeRow event, set the value of the unbound column cell to the ListObject property of the row. This gives you a c olumn that contains the clsTypeB object and you can use this unbound column as the ValueMember of the DropDown.

    2) Instead of using an UltraDropDown, use a BindableValueList and set the ValueMember to BindableValueList.USE_LISTOBJECT_AS_VALUEMEMBER

Children