ComponentOne True DBGrid for WinForms
Cell Editing Techniques / Working with Text / Providing a Drop-Down Edit Control for Long Fields
In This Topic
    Providing a Drop-Down Edit Control for Long Fields
    In This Topic

    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 wrapped 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:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    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
    

    To write code in C#

    C#
    Copy Code
    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; 
    }
    

    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.