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
890
How do I bind a custom class with a subclass?
posted

Hi all,

The result I'm looking to acheive here is that the user is presented with a grid of notes, and when they want to add a new note, they type into a "NoteText" column on the bottom row, and select a "Note Type" from a DropDown column on the bottom row.

Please consider my scenario:

I have a class structure that looks like this (but can be changed as required):

clsNotes

    clsNote

        clsNoteTypes

            clsNoteType

 

Let's say clsNote also has a "NoteID" property and a "NoteText" property, and that clsNoteType also has a "RecID" property and a "Description" property.

On my form, I instantiate MyNotesObject as clsNotes and bind it to my UltraGrid.  In my UltraGrid I now see 2 columns: "NoteID" and "NoteText" - but alas where is my "note type"?

HERE IS MY QUESTION:  What is the accepted way (if any) of having my clsNoteTypes class appear AS A DROPDOWN column in my UltraGrid?

 Any information or reference material pertaining to this issue will be appreciated.

Regards,

Scott Pearce

Parents
  • 469350
    Verified Answer
    Offline posted

     Hi Scott,

    In order to acheive this, what you would need to do is add a property to the Node called "NoteType". This would be a numeric field that equates to the RecID of the NoteType. 

    Then you need to use a ValueList on the grid column to provide a dropdown list. You will probably want to bind this list to your clsNoteTypes class. You have a couple of options for the list: you could use a ValueList or an UltraDropDown. For a simply list like this, I recommend the ValueList and since it's going to be bound, you will want to use a BindableValueList. If you create a BindableValueList and bind it to the clsNoteTypes list, you would set the ValueMember to "RecID" and the DisplayMember to "Description" and then set the ValueList property of the column to this BindableValueList. The BindableValueList takes care of the rest, storing the ID in the grid cell, but displaying the description to the user. 

     

Reply Children