Cell Editing Techniques > Working with Text > Providing a drop-down edit control for long fields |
Whenever the user attempts to edit cell text that is too big to fit within the cell, the grid will automatically activate a multiple-line drop-down text editor. While editing, text in the drop-down edit control will be wordwrapped regardless of the setting of the column's WrapText property. You can turn off the drop-down text editor and force editing to occur within cell boundaries by setting the grid's EditDropDown property to False (the default is True). The drop-down text editor is not available if the grid's MarqueeStyle property is set to 6 - Floating Editor. The following code uses the grid's built-in column button feature to activate the drop-down edit control to modify the cell data in the Comments column:
Example Title |
Copy Code
|
---|---|
Private Sub Form_Load() With TDBGrid1 .MarqueeStyle = dbgSolidCellBorder .Columns("Comments").Button = True ' Redundant since default = True. .EditDropDown = True End With End Sub Private Sub TDBGrid1_ButtonClick(ByVal ColIndex As Integer) ' Place the cell into edit mode. TDBGrid1.EditActive = True End Sub |
If the current cell is in the Comments column, you can initiate editing either by clicking on the current cell or by clicking the built-in button.