-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettings.cs
46 lines (40 loc) · 1.52 KB
/
Settings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Windows.Forms;
using System.Reflection; // change column width of a propertygrid
namespace GrzBeamProfiler
{
public partial class Settings: Form
{
public AppSettings Setting;
public Settings(AppSettings settings)
{
InitializeComponent();
this.propertyGrid.SelectedObject = settings;
}
// end settings dialog with ok
private void buttonOk_Click( object sender, EventArgs e )
{
Setting = (AppSettings)this.propertyGrid.SelectedObject;
}
// change column width of a propertygrid: https://stackoverflow.com/questions/12447156/how-can-i-set-the-column-width-of-a-property-grid 2nd answer
public static void SetLabelColumnWidth( PropertyGrid grid, int width )
{
if ( grid == null )
return;
FieldInfo fi = grid.GetType().GetField("gridView", BindingFlags.Instance | BindingFlags.NonPublic);
if ( fi == null )
return;
Control view = fi.GetValue(grid) as Control;
if ( view == null )
return;
MethodInfo mi = view.GetType().GetMethod("MoveSplitterTo", BindingFlags.Instance | BindingFlags.NonPublic);
if ( mi == null )
return;
mi.Invoke(view, new object[] { width });
}
private void Settings_Load( object sender, EventArgs e )
{
SetLabelColumnWidth(this.propertyGrid, 180);
}
}
}