Programmatically resize a column in a Windows Forms property grid control

Using the standard Microsoft .NET 2.0 WinForms PropertyGridControl control, I was looking for a way to set the size of the two columns (one for the labels, one for the values) so that I can control better how the values are displayed.

After some research with ILSpy on the .NET sources, I found a way to use with reflection. The following helper method can be used for this task:

public static void ResizePropertyGridSplitter(
    PropertyGrid propertyGrid,
    int labelColumnPercentageWidth)
{
    var width =
        propertyGrid.Width*(labelColumnPercentageWidth/100.0);

    // Go up in hierarchy until found real property grid type.
    var realType = propertyGrid.GetType();
    while (realType!=null && realType != typeof(PropertyGrid))
    {
        realType = realType.BaseType;
    }

    var gvf = realType.GetField(@"gridView",
        BindingFlags.NonPublic |
        BindingFlags.GetField |
        BindingFlags.Instance);
    var gv = gvf.GetValue(propertyGrid);

    var mtf = gv.GetType().GetMethod(@"MoveSplitterTo",
        BindingFlags.NonPublic |
        BindingFlags.InvokeMethod |
        BindingFlags.Instance);
    mtf.Invoke(gv, new object[] { (int)width });
}

Call the function and pass your PropertyGrid instance and width values between e.g. 10 and 90 to resize the first column to the given percentage value.

E.g.:

ResizePropertyGridSplitter( myPropGrid, 75 );

If you specify a too small or too large value, the PropertyGrid seems to use the minimum/maximum possible, based on your passed value.

Headset GN9350 an Telefon Alcatel 4039 betreiben

Seit mehreren Jahren habe ich ein DECT-Headset GN9350. Das betreiben wir an einer Alcatel-Anlage mit einem Endgerät 4039.

Da ich von Zeit zu Zeit immer wieder mal neu konfigurieren muss, hier für mich als Erinnerung mal die Anleitung, was zu tun ist beim Konfigurieren:

  • Alles verkabeln.
  • Einstellung im LC-Display auf „MSH“ und dann „OK“ drücken, so dass der Stern „*“ neben dem „MSH“ angezeigt wird.
  • Den Telefon-Setup-Schiebeschalter (A-G) auf „A“ stellen.
  • Die Lautstärke im LC-Display am besten auf „7“ (von 12) stellen.

Wichtige Hinweise:

  • Im Telefon muss als Rufton Standard, Nature oder Cold River eingestellt sein, damit eine Signalisierung des Ruftons im Headset statt findet. Dies geht über Menü > Einstellung > Rufton > Intern / extern
  • Außerdem müssen folgende Optionen auf „aus“ gestellt sein: Menü > Einstellung > Telefon > Intern / extern > weitere Optionen > Kein Ton, Progressiv, Pieptöne.

Die Anleitung gibt’s auch so ähnlich als PDFEin Handbuch zum GN Netcom GN9350 findet sich hier.

Neuer Sohn, neues (zusätzliches) Blog

Nachdem es uns viel Spaß gemacht hat, Janas Schwangerschaftserlebnisse im Schwangerschaftstagebuch-Blog zu dokumentieren, liegt die Überlegung nahe, das adäquat fortzusetzen.

Gesagt, getan, „koscht ja nix“ wie der Schwabe sagt. Deshalb:

FelixMaximus.com

ist ab sofort der Platz der Wahl wenn es darum geht, die Entwicklung eines Kindes zu verfolgen, vermutlich auch die Verwandlung von 2 Personen in Eltern. Das kann spannend werden, zumindest für uns.

Ich freue mich, wenn Ihr ab und zu mal vorbeischaut.

Felix Keim

Es ist unfassbar (zumindest für mich): Jana und Uwe sind Eltern geworden. Kurzfassung:

  • Freitagmorgen Einleitungsversuch
  • Freitagabend Fruchtblase geplatzt
  • Freitagnacht PDA
  • Samstag gegen 4 doch Kaiserschnitt
  • Samstag gegen 5: Felix ist da!
  • 52 cm, 37 cm Kopfumfang, 3,7 kg
  • Kind Felix gesund
  • Mutter gesund und hocherfreut
  • Uwe gesund und hocherfreut

Ich bin komplett hin-und-weg, alles ziemlich unfassbar. Unglaublich schönes Gefühl!

Subclassing the FileOpen dialog in .NET

If you are looking for a way to subclass a standard file open dialog from .NET, take a look at the Vista Bridge Sample Library from Microsoft.

„Subclassing“ (or „Extending“, „Customizing“) refers to adding new controls to the bottom of the standard Windows dialog like following, to extend it:

Although the examples are for WPF, I guess it is rather simple to migrate them to WinForms (.NET 2.0).