View previous topic :: View next topic |
Author |
Message |
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Sat Jan 26, 2008 12:02 am Post subject: Celleditor questions |
|
|
Hi,
I amplanning to use a celleditor control in a virtualtree but have a couple of queries. The vt I want to add the celleditor to uses object binding with 2 columns of data. Below is a diagram of the data table:
---------------------------------
ID | Value
---------------------------------
0 | age
1 | gender
2 | status
3 | children
4 | address
I;ve added the editor to the "Value" column using the following code:
Code: | col.CellEditor = New CellEditor(filePropEditBox) |
The problem is that this causes the editor to appear for every row in the Value column. How can I make it so that the editor only appears on certain rows depending on their ID. For example, if the ID is an odd number then the celleditor should appear, otherwise not.
My 2nd question relates to the editor itself. I would like to use a combobox control as the editor and fill it with different items each time it is invoked. The items it contains should obviously depend on the row that is selected. Is there some way to take control of the editor when it is initialised i.e. when the user selects a row? |
|
Back to top |
|
|
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Sun Jan 27, 2008 5:47 pm Post subject: |
|
|
Ok, i figured out how to get data from the row when the celleditor is initialised. I just used the cellEditor.InitializeControl handler to take control of the editor and then used the row data property to get information from the tree:
Code: | Private Sub fileDetEditor_Initialize(ByVal sender As System.Object, ByVal e As CellEditorInitializeEventArgs) Handles fileDetEditor.InitializeControl
Dim row As DataRow = DetPropVT.SelectedItem
'Do stuff...
End Sub
|
But I still can't choose when to make the editor appear... |
|
Back to top |
|
|
WaqasK
Joined: 21 Oct 2006 Posts: 32
|
Posted: Mon Jan 28, 2008 1:02 am Post subject: |
|
|
Ok, I've managed to work out a solution for when to make the editor appear. I just set the enabled property for the combobox to true or false depending on whether i wanted to display it for a particular row:
Code: |
Private Sub fileDetEditor_Initialize(ByVal sender As System.Object, ByVal e As CellEditorInitializeEventArgs) Handles fileDetEditor.InitializeControl
'get row data
Dim row As DataRow = DetPropVT.SelectedItem
' set a combo box as the celleditor control
Dim newBox As ComboBox = e.Control
'change enabled state of combobox (hence also the celleditor)
If row.Item(4) = "Yes" Then
newBox.Enabled = True
Else
newBox.Enabled = False
End If
End Sub
|
|
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Mon Jan 28, 2008 4:34 am Post subject: |
|
|
Quote: | But I still can't choose when to make the editor appear... |
Instead of setting the Editor for the column you can set the Editor for individual RowBindings (via the Virtual Tree editor) or programmatically by handling the GetCellData event and setting the e.CellData.Editor property. If you are using object binding then look at the section in the online help on mixing Programmatic binding with object binding. _________________ Infralution Support |
|
Back to top |
|
|
|