سؤال

أي شيء مع سلسلة طويلة ببساطة يقدم عرض غير قابل للاستخدام مع شريط التمرير ..

هل العرض على محرر جمع التجميع الذي تم إصلاحه من قبل التصميم ويمكن إدخال الخائن في هذا العرض التقديمي الرائع؟

هل كانت مفيدة؟

المحلول

أنا لم أر طريقة للقيام بذلك بانتظام PropertyGrid, ، ولكن إذا كنت لا تمانع في الدفع، فإن VisualHint لديها عرض أكثر تطورا هنا - ربما محاكمة ذلك.


هذا يفعل الوظيفة باستخدام التفكير؛ استخدم بحذر...

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 });
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top