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 style’s WrapText property. The drop-down text editor can be turned off and editing can be forced 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 MarqueeEnum.FloatingEditor. 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:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me.C1TrueDBGrid1
.MarqueeStyle = MarqueeEnum.SolidCellBorder
.Splits(0).DisplayColumns("Comments").Button = True
' Redundant since default = True.
.EditDropDown = True
End With
End Sub
Private Sub C1TrueDBGrid1_ButtonClick(ByVal sender As Object, ByVal e As C1.Win.C1TrueDBGrid.ColEventArgs) Handles C1TrueDBGrid1.ButtonClick
' Place the cell into edit mode.
Me.C1TrueDBGrid1.EditActive = True
End Sub
· C#
private void Form1_Load( System.object sender, System.EventArgs e)
{
C1TrueDBGrid1.MarqueeStyle = MarqueeEnum.SolidCellBorder;
C1TrueDBGrid1.Splits[0].DisplayColumns["Comments"].Button = true;
// Redundant since default = true.
C1TrueDBGrid1.EditDropDown = true;
}
private void C1TrueDBGrid1_ButtonClick( object sender, C1.Win.C1TrueDBGrid.ColEventArgs e)
{
// Place the cell into edit mode.
this.C1TrueDBGrid1.EditActive = true;
}
· Delphi
procedure TWinForm.TWinForm_Load(sender: System.Object; e: System.EventArgs);
begin
with Self.C1TrueDBGrid1 do
begin
MarqueeStyle := MarqueeEnum.SolidCellBorder;
Splits[0].DisplayColumns['Comments'].Button := true;
// Redundant since default = True.
EditDropDown := True;
end
end;
procedure TWinForm.C1TrueDBGrid1_ButtonClick(sender: Object; e: C1.Win.C1TrueDBGrid.ColEventArgs);
begin
// Place the cell into edit mode.
Self.C1TrueDBGrid1.EditActive := True;
end;
If the current cell is in the Comments column, initiate editing either by clicking on the current cell or by clicking the built-in button.
Send comments about this topic to ComponentOne. Copyright © ComponentOne LLC. All rights reserved. |