WinForm GridView

5 posts, 0 answers
  1. Quyen
    Quyen avatar
    9 posts
    Member since:
    Dec 2007

    Posted 20 Dec 2007 Link to this post

    I have 2 questions

       How do i make the grid view resize to fit the form size when click on the maximize   i.e something like width = 100%

    2- How do I create a custom Context menu from a gridview?
  2. OneZero
    OneZero avatar
    4 posts
    Member since:
    Jul 2007

    Posted 21 Dec 2007 Link to this post

    1. Set the gridView Dock property to Fill
    2. Make a CustomContextMenuStrip and set it as a property Context Menu of the grid (don't forget to disable the AllowCellContextMenu property).

    I hope it solves your problems.
  3. Jack
    Jack avatar
    2333 posts

    Posted 21 Dec 2007 Link to this post

    Hi Quyen Ho,

    Thank you for writing us.

    You have two options to synchronize RadGridView size with its parent form size:

    1. Use the Dock property of RadGridView. Set it to a value of Fill. This way the control will resize to fill the available size in the form.
    2. Use the Anchor property of RadGridView. Set it to Left, Right, Top, and Bottom. The size of the grid will adjust to fill the form area.
    If you wish to have the grid columns fill the whole available size set the AutoSizeColumnMode property of MasterGridViewInfo to Fill. Refer to the code below:

    this.radGridView1.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; 

    Currently, the easiest way of customizing the ContextMenu in the grid is to inherit from the RadGridView class. We will improve this in our future releases. The following sample demonstrates this behavior:

    public class MyGridView : RadGridView 
        protected override void OnMouseDown(MouseEventArgs e) 
            if (e.Button == MouseButtons.Right) 
                RadDropDownMenu menu = new RadDropDownMenu(); 
                menu.Items.Add(new RadMenuItem("Item 1")); 
                menu.Items.Add(new RadMenuItem("Item 2")); 
                menu.Items.Add(new RadMenuItem("Item 3")); 
                menu.Show(this, e.Location); 
        public override string ThemeClassName 
                return typeof(RadGridView).FullName; 

    In case you have further questions, do not hesitate to contact us.

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  4. Doug
    Doug avatar
    50 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2013 Link to this post

    Can you set the AutoSizeColumnsMode for just one column?

    I tried myGridView.MasterGridViewInfo.ViewTemplate.Columns["myColumn"]. ... and couldn't get the AutoSizeColumnMode property to show up.
  5. Stefan
    Stefan avatar
    2911 posts

    Posted 26 Jul 2013 Link to this post

    Hello Gary,

    As the property name implies it concerns multiple columns and it controls all columns in a template. Such property does not exist of per column level and this is why you cannot find it. If you want to make a column wide enough to display its contents, you can call its BestFit method. 

    More information about this matter is available here:

    I hope this helps.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top