Home Forums WinForms controls Xceed Grid for WinForms Extend Right Column

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #12969 |

    In some others grid i found the ExtendRightColumn property, which automatically extend the size of the last column to fill the width of the grid.
    Is there someting similar in Xceed Grid 2?
    Thanks.

    Imported from legacy forums. Posted by Gian Luigi (had 3086 views)

    User (Old forums)
    Member
    Post count: 23064

    Hello!
    I asked the same question and got this sample code from Xceed.
    Hope it helps you.

    //Subscribe on these events in the Form_Load() section
    foreach(Xceed.Grid.Column c in gridControl1.Columns)
    {
    c.WidthChanged += new EventHandler(this.Column_WidthChanged);
    c.VisibleIndexChanged += new EventHandler(this.Column_VisibleIndexChanged);
    }

    //Add these event methods.
    private void Column_WidthChanged(object sender, EventArgs e)
    {
    ResizeLastColumn();
    }

    private void Column_VisibleIndexChanged(object sender, EventArgs e)
    {
    ResizeLastColumn();
    }

    //Add this method.
    private void ResizeLastColumn()
    {

    int spaceLeft = gridControl1.DisplayRectangle.Width – gridControl1.RowSelectorPane.Width;

    for(int cpt = 0; cpt < gridControl1.Columns.Count – 1; cpt ++)
    {
    spaceLeft -= gridControl1.Columns.GetColumnAtVisibleIndex(cpt).Width;
    }

    gridControl1.Columns.GetColumnAtVisibleIndex(2).Width = spaceLeft;

    }

    Imported from legacy forums. Posted by Benny (had 434 views)

    User (Old forums)
    Member
    Post count: 23064

    Thanks for your reply.
    I try your code (i have converted it in VB.Net), but in ResizeLastColumn it considers ALL columns, even that not visible in the displayrectangle.
    So Spaceleft is always negative and this don’t work for me.
    Do you know if there is a method to know if a column is in the display rectangle?

    Thanks.

    Imported from legacy forums. Posted by Gian Luigi (had 211 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi skysurfer72!

    I’m sorry for replying so slowly.

    Unfortunately i do not know if there is such a method, but maybe the Xceed staff know how to handle this problem.

    Regards,

    Imported from legacy forums. Posted by Benny (had 4121 views)

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.