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

Best way to set the location for RadGridView ColumnChooser dialog box

1 Answer 168 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Abhay
Top achievements
Rank 1
Abhay asked on 09 May 2012, 03:40 AM
Hi,

What's the intended/best way of setting the location for RadGridView's ColumnChooser dialog box? I want to show it at the center of the calling application (ideally) or at least within the bounds of the calling application.

I tried using ColumnChooser.StartPosition = FormStartPosition.CenterParent but it didn't work. May be because its Parent or MdiParent is set to NULL (I found this while debugging).

Thus currently I am setting the DesktopLocation property of ColumnChooser to the DesktopLocation of ParentForm offset by (50, 50).

//Since workListRadGridView.ColumnChooser's Parent or MdiParent property is not set,
//setting its StartPosition to FormStartPosition.CenterParent doesn't work.
//As a workaround, get parent form's desktop location and offset it 50 pixels from
//both X and Y co-ordinates to keep the column chooser within the bounds of the application.
//Parent form desktop location.
//DesktopLocation property is idle choice because of the following remark in its documentation on MSDN:
//"If your application is running on a multimonitor system, the coordinates of the form are the coordinates for the combined desktop."
//Telerik's documentation for ColumnChooser also has the mention for DesktopLocation property.
//(though not in the context of "setting the location")
 
if (this.ParentForm != null
    && this.ParentForm.DesktopLocation != null)
{
    Point columnChooserDesktopLocation = new Point(this.ParentForm.DesktopLocation.X, this.ParentForm.DesktopLocation.Y);
    columnChooserDesktopLocation.Offset(50, 50);
    radGridView.ColumnChooser.DesktopLocation = columnChooserDesktopLocation;
}


But I am bit apprehensive of ParentForm being NULL or this approach not working correctly for some reason. Thus needed to know if there exists a better way of specifying the location of the ColumnChooser.

Also, more importantly, I want the above code to work even if the user has more than one monitor/display unit.

Thanks,
~Abhay

1 Answer, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 11 May 2012, 04:40 PM
Hello Abhay,

Thank you for writing.

In order to assign a parent of the column chooser, you should set its Owner property to the form instance. Then, the CenterParent setting will be taken into consideration. Here is an example:
this.rgv_sample.ColumnChooser.Owner = this;
this.rgv_sample.ColumnChooser.StartPosition = FormStartPosition.CenterParent;
 
Point columnChooserDesktopLocation = new Point(this.DesktopLocation.X, this.DesktopLocation.Y);
columnChooserDesktopLocation.Offset(50, 50);
this.rgv_sample.ColumnChooser.Location = columnChooserDesktopLocation;

I hope that the provided information addresses your question. Should you have any other questions, do not hesitate to contact us.

Regards,
Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Abhay
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or