2 posts, 1 answers
  1. Behin
    Behin avatar
    12 posts
    Member since:
    Oct 2012

    Posted 14 Oct 2012 Link to this post

    I have a trackbar and a grid in my form ,I want to change the width of grid columns by scrolling the trackbar, for example when I scrool to right the columns width change to columns width +5and when I scroll trackbar to the left  the columns width change to columns width -5.
    please help me to do this.
    thanks alot
  2. Answer
    Anton avatar
    167 posts

    Posted 17 Oct 2012 Link to this post

    Hi Behin,

    Thank you for writing.

    To achieve the desired functionality, simply subscribe to the Scroll or the ValueChanged event and use following code snippet:
    if (this.radTrackBar1.Value > oldValue)
        foreach (GridViewColumn item in this.radGridView1.Columns)
            item.Width += (this.radTrackBar1.Value - oldValue) * 5;
        foreach (GridViewColumn item in this.radGridView1.Columns)
            item.Width -= (oldValue - this.radTrackBar1.Value) * 5;
    oldValue = this.radTrackBar1.Value;
    Attached is a sample project.

    I hope this information helps. If you have further questions, feel free to write back

    the Telerik team
    You’ve been asking for it and now it’s time for us to deliver. RadControls for WinForms Q3 2012 release is just around the corner. Sign up for a free webinar to see first all the latest enhancements.
Back to Top