Home › Forums › WinForms controls › Xceed Grid for WinForms › edit ComboBoxEditor
-
AuthorPosts
-
#16001 |
Hi,
I have a comboBoxEditor set up with values in a grid cell. I am working on a update screen that displays one table record (a field in every column cell of my display) the user can select a value from the combobox to change the field value for that record.
However, I also want them to be able to type a new value in the cell (which has the combobox on it) so I can select that cell value and update the record.
Is this possible?
If so how?vb.net please.
Imported from legacy forums. Posted by troy@querytool.com (had 3432 views)
Yes, it’s possible. Here, I did not handle all the possibilities (double values, validation, …). However, it should get you started.
<code>
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
For j As Integer = 0 To 3
Dim col As Column = New Column(“Column” & j.ToString())
gridControl1.Columns.Add(col)
Next jwcb = New WinComboBox(EnhancedBorderStyle.None)
For i As Integer = 0 To 19
Dim row As Xceed.Grid.DataRow = gridControl1.DataRows.AddNew()
For Each cell As Cell In row.Cells
cell.Value = “Item ” & i.ToString()
Next cell
wcb.Items.Add(“Item ” & i.ToString())
row.EndEdit()
Next igridControl1.Columns(0).CellEditorManager = New ComboBoxEditor(wcb)
AddHandler gridControl1.Columns(0).CellEditorManager.DeactivatingControl, AddressOf CellEditorManager_DeactivatingControl
End SubPrivate wcb As WinComboBox
Private Sub CellEditorManager_DeactivatingControl(ByVal sender As Object, ByVal e As CellEditorEventArgs)
wcb.Items.Add((CType(e.Control, WinComboBox)).TextBoxArea.Text)
End Sub
</code>Imported from legacy forums. Posted by CharlesB (had 266 views)
Thanks – works well.
Couple of quick questions:
1. I set up the dropdown in a specific cell when the user clicks a button, once they move on to another cell I Dispose of the celleditormanager: xg.DataRows(0).Cells(1).CellEditorManager.Dispose()
If the user comes back to the cell, I want it to be editable (without the dropdown), but I find I can’t change the value of that cell anymore (it’s not set to Readonly)
Any ideas?2. Also, is there a property to set the column width to the lenght of the column title?
thanks
Imported from legacy forums. Posted by troy@querytool.com (had 337 views)
1. The problem is that you need a CellEditorManager to edit a cell. Before you add your ComboBoxEditor, there is a default TextEditor. However, after disposing of the CellEditorManager (ComboBoxEditor), you need to re-assign a TextEditor (to be able to edit it).
2. You can use the GetFittedWidth() method from the ColumnManagerCell. Here is a snippet that shows how it could be done:
gridControl1.Columns(0).Width = DirectCast(gridControl1.FixedHeaderRows(1), ColumnManagerRow).Cells(0).GetFittedWidth()
Imported from legacy forums. Posted by CharlesB (had 4956 views)
-
AuthorPosts
- You must be logged in to reply to this topic.