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
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.
Thanks for your help - I'm now adding an unbound column to my grid, and setting it's ValueList to be a "bindable value list" variable, which is bound to my clsNoteTypes class.
So now I have a grid bound to my clsNotes class. Picture what I have in your mind: The grid is now populated - I have a bunch of rows, each with bound columns "NoteText", "Creation Date", etc. There is also "NoteType_RecID" column. Next to that is the drop down list of all possible note types (an unbound column, created as you instructed above) - the DisplayMember of this dropdown is "Description" and the ValueMember is "RecID"
My questions relating the above scenario:
1. How do I set the value of the drop down column such that the note type that corresponds with the "NoteType_RecID" for that row is showing?
2. How exactly should I handle things when the user changes the drop down value?
Thanks for any answers you can provide. I know it's tough to do this sort of thing without "seeing" the actual code.
Regards.
Scott
Scott Pearce said:1. How do I set the value of the drop down column such that the note type that corresponds with the "NoteType_RecID" for that row is showing?
You just set the Value of the cell to the appropriate Rec_ID and the grid will display the matching description from the list.
Scott Pearce said:2. How exactly should I handle things when the user changes the drop down value?
Handle what, exactly? When the user selects an item from the list, the cell's Value will be set to the Rec_Id for the item they selected. But the cell will display the Description to the user. So there should not be anything to handle.
Mike Saltzman"]Handle what, exactly?
Pushing the value chosen from the UI (grid) back to the business logic that the grid is bound to. Looks like I have to handle this manually - on selected value changed set the appropriate class property to the current value of the cell. Please confirm. I think i'm straightened out now..
Thanks again Mike. I'm all set with this now. I'll mark this as answered.
When you select a row from the dropdown list, the Value property of the grid cell will be set to the ID (as determined by the ValueMember field) of the selected item. So you don't have to do anything to get the grid cell value to update.
The grid will automatically update the data source when you leave the cell or lose focus on the grid, as determined by the UpdateMode property.
If you are talking about getting the value from the grid's data source into the database or the back end, then yes, you need to handle that part separately from the grid.