FlexGrid - Scroll bars for a single cell

Posted by: kreiger on 7 March 2018, 3:31 pm EST

    • Post Options:
    • Link

    Posted 7 March 2018, 3:31 pm EST

    I have a grid that has a cell with large amounts of text. I can’t figure out how to create scroll bars inside that cell when its selected. I’m assuming I have to do something with owner draw but I can’t figure it out…

  • Posted 8 March 2018, 1:12 am EST

    Hi Michael!

    I would like to suggest you a simpler way for this, using Editor property of column and AfterRowColChange event of the grid.

    You can set following properties of TextBox control and assign this to the column’s Editor :

    TextBox txtBox = new TextBox();
    txtBox.Multiline = true;
    txtBox.ScrollBars = ScrollBars.Both;
    txtBox.WordWrap = true;
    c1FlexGrid1.Cols[1].Editor = txtBox;
    

    Next, you can start editing for the selected cell.

    private void C1FlexGrid1_AfterRowColChange(object sender, RangeEventArgs e)
    {
                if(c1FlexGrid1.Cols[e.NewRange.c1].Editor is TextBox)
                {
                    TextBox txtBox = c1FlexGrid1.Cols[e.NewRange.c1].Editor as TextBox;
                    c1FlexGrid1.StartEditing(e.NewRange.r1, e.NewRange.c1);
                    txtBox.SelectionStart = txtBox.Text.Length;
                }
    }
    

    Attached is the sample for your reference.

    Prj_ScrollbarsInCell.zip

    Best regards,

    Meenakshi

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels