FlexGrid for WinForms

Is there a way to AutoSizeRow while editing multi-line text?

  •  ou81aswell said 1 year, 5 months ago:

    Is there a way to autosize a row as it is being edited? I would like to increase the row height if the user enters multiple lines of text in a particular cell.

    Thanks.

  •  Ashish Jindal16p said 1 year, 5 months ago:

    Hello,

    You can handle the KeyDownEdit event of the flexgrid and if he is entering multiple lines then can increase the height of the textbox. Here is the code for same:

    VB

     Private Sub C1FlexGrid1_KeyDownEdit(sender As Object, e As C1.Win.C1FlexGrid.KeyEditEventArgs) Handles C1FlexGrid1.KeyDownEdit
    
            If e.KeyCode = Keys.Enter And e.Shift Then
              ' This is to check whether text cursor is on the last line or not
                Dim txtbx As TextBox = C1FlexGrid1.Editor
                If (txtbx.Lines.Length – 1) = txtbx.GetLineFromCharIndex(txtbx.GetFirstCharIndexOfCurrentLine) Then
                    C1FlexGrid1.Rows(e.Row).Height += 20
                End If
            End If
         End Sub
    

    C#

    private void C1FlexGrid1_KeyDownEdit(object sender, C1.Win.C1FlexGrid.KeyEditEventArgs e)
    {
    	if (e.KeyCode == Keys.Enter & e.Shift) {
         // This is to check whether text cursor is on the last line or not
    		TextBox txtbx = C1FlexGrid1.Editor;
    		if ((txtbx.Lines.Length – 1) == txtbx.GetLineFromCharIndex(txtbx.GetFirstCharIndexOfCurrentLine)) {
    			C1FlexGrid1.Rows(e.Row).Height += 20;
    		}
    
    	}
    
    }
    
    

    Regards
    Ashish

    Answer
  •  ou81aswell said 1 year, 5 months ago:

    Great! I was close. I was resizing the row on the keydownedit event. Of course, this didn’t resize the textbox. Many thanks (again).

    Cheers!

  •  ou81aswell said 1 year, 5 months ago:

    Out of interest, how does one copy and paste the code fragments above. I used a simple copy / paste from IE9 to my text editor (VS 2010) but the code ended up on a single line.

  •  Ashish Jindal16p said 1 year, 5 months ago:

    Hello,

    Yes, it seems to some issue with IE. I have escalated it to the concerned team for review, in between, you can use any other browser for same.

    Regards
    Ashish

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.