User (Old forums)MemberApril 1, 2008 at 8:05 pmPost count: 23064
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?
Imported from legacy forums. Posted by firstname.lastname@example.org (had 3432 views)Xceed SupportMemberApril 2, 2008 at 11:25 amPost count: 5658
Yes, it’s possible. Here, I did not handle all the possibilities (double values, validation, …). However, it should get you started.
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())
wcb = 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()
wcb.Items.Add(“Item ” & i.ToString())
gridControl1.Columns(0).CellEditorManager = New ComboBoxEditor(wcb)
AddHandler gridControl1.Columns(0).CellEditorManager.DeactivatingControl, AddressOf CellEditorManager_DeactivatingControl
Private wcb As WinComboBox
Private Sub CellEditorManager_DeactivatingControl(ByVal sender As Object, ByVal e As CellEditorEventArgs)
Imported from legacy forums. Posted by CharlesB (had 266 views)User (Old forums)MemberApril 3, 2008 at 5:02 pmPost count: 23064
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)
2. Also, is there a property to set the column width to the lenght of the column title?
Imported from legacy forums. Posted by email@example.com (had 337 views)Xceed SupportMemberApril 4, 2008 at 3:27 pmPost count: 5658
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)
- You must be logged in to reply to this topic.