Extend Group Row with custom controls

Posted by: abellisomi on 5 March 2018, 8:04 am EST

    • Post Options:
    • Link

    Posted 5 March 2018, 8:04 am EST

    Hello, I would like to show in every Group Rows a texbox and fire an event on TextChanged. Is it possible to do it while keeping the existing behavior (e.g. toggle feature) and style? Thanks

  • Posted 6 March 2018, 8:12 am EST

    Hello,

    Though, there is no direct way of adding a TextBox to GroupRow, you can still create a Custom CellFactory inheriting CellFactory, implement its CreateOutlineCellContent method and add TextBox as follows: ```

    void CreateOutlineCellContent(C1FlexGrid grid, Border bdr, CellRange range)

    {

    var gr = row as GroupRow;

            if (gr != null)
            {             
                // copy data from original cell
                [b]var p = bdr.Child as Panel;  [/b]    
                 var g = CreateCellGrid(row, gr.Level, grid.TreeIndent, img);          
                if (p != null && p.Children.Count > 1)
                {
                    var tb = p.Children[1] as FrameworkElement;
                    p.Children.Clear();
                    tb.VerticalAlignment = VerticalAlignment.Center;
                    tb.Margin = new Thickness(4, 0, 0, 0);
                    tb.SetValue(Grid.ColumnProperty, gr.Level + 1);
                    g.Children.Add(tb);
                    [b]TextBox myTb= new TextBox();            
                    myTb.TextChanged += myTb_TextChanged;
                    myTb.Text = "Custom Text";
                    g.Children.Add(myTb);[/b]
    
                    // assign grid to cell
                    bdr.Padding = _thickness;
                    bdr.Margin = _thicknessEmpty;
                    bdr.Child = g;
                }
            }
    
    For complete implementation, you may refer [b]'ExcelBook'[/b] product sample located at [i]..\Documents\ComponentOne Samples\WPF\C1.WPF.FlexGrid\CS\ExcelBook\ExcelBook [/i] location in machine.
    
    Thanks,
    Ruchir Agarwal
Need extra support?

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

Learn More

Forum Channels