Question

Quelque chose avec une longue chaîne présente simplement une vue inutilisable avec une barre de défilement ..

est la largeur de l'éditeur de collection fixé par la conception et un séparateur peut être présenté à cette présentation impressionnante?

Était-ce utile?

La solution

Je ne l'ai pas vu une façon de le faire avec PropertyGrid régulière, mais si vous ne rechignent pas à payer, Visualhint une offre beaucoup plus développée ici -. peut-être procès, il


fait le travail en utilisant la réflexion; utiliser avec précaution ...

using System;
using System.Reflection;
using System.Windows.Forms;
class Program {
    [STAThread]
    static void Main() {
        Application.EnableVisualStyles();
        Form form = new Form();
        // this bar will control the splitter
        ScrollBar sb = new HScrollBar {
            Minimum = 10, Maximum = 200,
            Dock = DockStyle.Bottom
        };
        // the grid we want to control
        PropertyGrid grid = new PropertyGrid {
            SelectedObject = form, Dock = DockStyle.Fill
        };
        // add to the form
        form.Controls.Add(grid);
        form.Controls.Add(sb);
        // event to update the grid
        sb.ValueChanged += delegate {
            MoveSplitterTo(grid, sb.Value);
        };
        Application.Run(form);
    }
    static void MoveSplitterTo(PropertyGrid grid, int x) {
        // HEALTH WARNING: reflection can be brittle...
        FieldInfo field = typeof(PropertyGrid)
            .GetField("gridView",
                BindingFlags.NonPublic | BindingFlags.Instance);
        field.FieldType
            .GetMethod("MoveSplitterTo", 
                BindingFlags.NonPublic | BindingFlags.Instance)
            .Invoke(field.GetValue(grid), new object[] { x });
    }
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top