How to add right boundary to grid

Posted by: samo3889 on 28 May 2018, 5:23 am EST

  • Posted 28 May 2018, 5:23 am EST - Updated 4 October 2022, 2:37 am EST

    Hi all

    i use DockStyle.Fill to Grid

    i want to add spaces in right side of Grid

    please look at the following Picture example what i mean exatly :

    it’s Available?

  • Posted 29 May 2018, 1:33 am EST

    Hi,

    Please note, this is the design behavior of C1FlexGrid if sum of all column’s width is greater them the width of C1FlexGrid then it does not display any blank area.

    However, you can try to use below work around. Hope it will help you.

            private void Form1_Load(object sender, EventArgs e)
            {
                //At the last of load event 
                //OR after assigning the data source of C1FlexGrid
                c1FlexGrid.Cols.Count += 1;
                c1FlexGrid.Cols[c1FlexGrid.Cols.Count - 1].AllowEditing = false;
    	    c1FlexGrid.Cols[c1FlexGrid.Cols.Count - 1].AllowDragging = false;
                c1FlexGrid.Cols[c1FlexGrid.Cols.Count - 1].Width = 40;
                c1FlexGrid.DrawMode = DrawModeEnum.OwnerDraw;
                c1FlexGrid.OwnerDrawCell += C1FlexGrid_OwnerDrawCell;
                c1FlexGrid.BeforeRowColChange += C1FlexGrid_BeforeRowColChange;
            }
    
            private void C1FlexGrid_BeforeRowColChange(object sender, RangeEventArgs e)
            {
                if (e.NewRange.IsSingleCell && e.NewRange.RightCol == (c1FlexGrid.Cols.Count-1))
                {
                    e.Cancel = true;
                }
            }
    
            private void C1FlexGrid_OwnerDrawCell(object sender, OwnerDrawCellEventArgs e)
            {
                if (e.Col == (c1FlexGrid.Cols.Count - 1))
                {
                    e.Graphics.FillRectangle(Brushes.Gray, e.Bounds);
                    e.Handled = true;
                }
            }
    

    Thanks,

    Singh

Need extra support?

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

Learn More

Forum Channels