This is a migrated thread and some comments may be shown as answers.

WinForm GridView

4 Answers 144 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Quyen
Top achievements
Rank 1
Quyen asked on 20 Dec 2007, 07:02 PM
Hi,
I have 2 questions

1-
   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?
 
Thanks

4 Answers, 1 is accepted

Sort by
0
OneZero
Top achievements
Rank 1
answered on 21 Dec 2007, 07:38 AM
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.
0
Jack
Telerik team
answered on 21 Dec 2007, 12:51 PM
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); 
        } 
        else 
        { 
            base.OnMouseDown(e); 
        } 
    } 
 
    public override string ThemeClassName 
    { 
        get 
        { 
            return typeof(RadGridView).FullName; 
        } 
        set 
        { 
        } 
    } 

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

Greetings,
Jack
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Doug
Top achievements
Rank 1
answered on 24 Jul 2013, 09:38 PM
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.
0
Stefan
Telerik team
answered on 26 Jul 2013, 05:29 AM
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: http://www.telerik.com/help/winforms/gridview-columns-resizing-columns-programatically.html.

I hope this helps.
 

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
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 >>
Tags
GridView
Asked by
Quyen
Top achievements
Rank 1
Answers by
OneZero
Top achievements
Rank 1
Jack
Telerik team
Doug
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or