View previous topic :: View next topic |
Author |
Message |
esanabia
Joined: 29 Sep 2008 Posts: 23
|
Posted: Sun Aug 23, 2009 12:56 am Post subject: Populated ComboBox as Editor |
|
|
I'm trying to use a combo box that is populated with items as an editor in my virtual tree (it's actually a modified combobox that display items as a tree when the user clicks the drop down, but I don't think it's relevant to my problem). I cannot bind the combo box to a datasource - I need to populate the items manually (i.e. combobox.add("Item 1").
I've added an editor in Designer (Edit Virtual Tree) and then set the Control property to my custom combobox. I have the DisplayMode set to "OnEdit". I then set my columns editor property to my Editor.
On the Form_Load event, I populate the combo box with my database items, but nothing appears in the drop down list.
I'm using vb.net. Please help. Thanks. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
|
Back to top |
|
|
esanabia
Joined: 29 Sep 2008 Posts: 23
|
Posted: Mon Aug 24, 2009 1:09 am Post subject: |
|
|
Thanks for the link. I added a handler to the CellEditor.InitializeControl event and it's working fine.
I'm having another issue with trying to add a new record... When a user opens the form, I populate the virtual tree with items the user had previously selected. The last item in the tree is just a blank record with a description of "Add new item". When the user clicks this row and selects an item from the the combo box, I want to add add a new record rather than update the existing row. This way there's always a "Add new item" row in the tree. I believe I should handle this in one of the vt events, but not sure.
Thanks for the help. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Aug 24, 2009 1:18 am Post subject: |
|
|
What type of data source are you binding to?
You could update the existing row, but then add another new row (so that you always have another row).
You probably want to handle the SetCellValue event to handle this as a special case.
Code: | Private Sub _virtualTree_SetCellValue(ByVal sender As Object, ByVal e As SetCellValueEventArgs) Handles _virtualTree.SetCellValue
' let the default binding set the value
'
Dim binding As RowBinding = _virtualTree.GetRowBinding(e.Row)
binding.SetCellValue(e.Row, e.Column, e.OldValue, e.NewValue)
' now check if e.Row.Item was a new row - how you do this depends on
' the type of data you are bound to - then add a new row
End Sub |
_________________ Infralution Support |
|
Back to top |
|
|
esanabia
Joined: 29 Sep 2008 Posts: 23
|
Posted: Mon Aug 24, 2009 4:24 am Post subject: |
|
|
I'm binding to a TypedList data source, like shown in the DatabaseBrowser sample. I updated the code in the SetCellValue and everything is working.
Thanks for all the help. |
|
Back to top |
|
|
|