.NET Framework - PropertyGrid Divider
Asked By Fritz Hilgemann
20-Nov-09 12:23 PM
Hallo,
ich habe wenig Hoffnung, nachdem ich online -noch- nichts dazu gefunden
habe:
Ein PropertyGrid zeigt in der Mitte einen Divider Strich zwischen Name und
Value.
Kann man den programmatisch auch verschieben? Es nervt, ihn jedesmal auf's
Neue händisch anzupassen.
Gruß, Fritz
SelectedGridItemChangedEventHandler
(1)
BindingFlags.InvokeMethod
(1)
BindingFlags.NonPublic
(1)
BindingFlags.GetField
(1)
BindingFlags.Instance
(1)
BindingFlags
(1)
EventArgs
(1)
InvokeMember
(1)
Frank Dzaebel replied to Fritz Hilgemann
Hallo Fritz,
;-)
Ein Beispiel:
private void Form1_Load(object sender, EventArgs e)
{
propertyGrid1.SelectedObject = this;
SpaltenSplitterBreite(propertyGrid1, 40);
}
/// <summary>Setzen der Breite des linken Namensbereiches des
/// PropertyGrids. G?nstig ist oft ein drittel der
Gesamtbreite.</summary>
/// Das PropertyGrid, das modifizioert werden
soll.
/// Die Breite in Pixeln.
private void SpaltenSplitterBreite(PropertyGrid grid, int width)
{
object gridView = typeof(PropertyGrid).InvokeMember(
BindingFlags.Instance, null, grid, null);
gridView.GetType().InvokeMember("MoveSplitterTo",
BindingFlags.InvokeMethod | BindingFlags.NonPublic |
BindingFlags.Instance, null, gridView, new object[] { width });
//propertyGrid1.SelectedGridItemChanged += new
SelectedGridItemChangedEventHandler(
// propertyGrid1_SelectedGridItemChanged);
}
Nat?rlich nicht 100% sauber, da private Methoden benutzt werden.
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP/MVP C#]
http://Dzaebel.NET
Fritz Hilgemann replied to Frank Dzaebel
Hallo Frank,
erstaunlich, wie "tief" man dafür reinlangen muß. Ich verstehe nicht, warum
das nicht ein normales Property sein kann, braucht doch jeder -:).
Aber jedenfalls, dies funktioniert prima. Besten Dank,
Fritz
the High o Datagrid-Rows void SetGridRowHeight(DataGrid dg, int rowNumber, int cy) { BindingFlags bf = BindingFlags.NonPublic | BindingFlags.Instance; ArrayList rows = (ArrayList)dg.GetType().GetField("m_rlrow", bf).GetValue(dg); object row = rows you can understand the problem. otherwhise ask for more details. Thanks .NET Compact Framework Discussions BindingFlags.NonPublic (1) BindingFlags.Instance (1) BindingFlags (1) ScrollBar (1) ArrayList (1) DataGrid (1) SetGridRowHeight (1) GetValue 1) You can show the scrollbar like this: ScrollBar sb = (ScrollBar)typeof(DataGrid).GetField("m_sbVert", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance).GetValue(dg); sb.Visible = true; keywords: How, to, force, the, Scrollbar
Bind Method on Event .NET Framework TValue oItem = (TValue)Activator.CreateInstance(typeof(TValue), BindingFlags.Instance | BindingFlags.NonPublic, null, new object[] { m_nCleTemporaire }, System.Globalization.CultureInfo.CurrentCulture); EventInfo oPropertyChanged = oItem.GetType().GetEvent("PropertyChanged"); MethodInfo eventHandler = this.GetType().GetMethod("Item_PropertyChanged", BindingFlags.Instance | BindingFlags.NonPublic); / * * Next code line fails * * / Delegate d = Delegate.CreateDelegate(oPropertyChanged.EventHandlerType, eventHandler); The system says that the delegate with the defined type. Why ??? Claude C# Discussions System.Globalization.CultureInfo.CurrentCulture (1) BindingFlags.NonPublic (1) OPropertyChanged.EventHandlerType (1) Activator.CreateInstance (1) Delegate.CreateDelegate (1) BindingFlags.Instance (1) BindingFlags (1) MethodInfo (1) BindingFlags.NonPublic, = A0 = A0 = A0 = A0 = A0 = A0 = A0 = A0 = A0 = A0 = A0 reInfo.CurrentCulture); ; Are you
associato il nome? Ciao Fabio C# - Italian Discussions System.Reflection.BindingFlags.IgnoreCase (1) System.Reflection.BindingFlags.NonPublic (1) System.Reflection.BindingFlags.Instance (1) System.Reflection.BindingFlags.Public (1) System.Reflection.FieldInfo (1) BindingFlags.NonPublic (1) System.Windows.Forms (1) CurrentForm.GetType (1) Senza ciclare i controlli. Ciao Fabio Con Dim info As System.Reflection.FieldInfo = _ CurrentForm.GetType().GetField("_" & Name, _ System.Reflection.BindingFlags.NonPublic Or _ System.Reflection.BindingFlags.Instance Or _ System.Reflection.BindingFlags.Public Or _ System WindowsForms? Se s?, puoi usare reflection: - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - var textBox = (TextBox) typeof(Form1) .GetField(controlName, BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(this); - -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - - - Matteo Migliore http: / / blogs.ugidotnet.org / matteomigliore blic) Si, la domanda era generica
a VBA macro in Word: _wordApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, _wordApp, argumentList); This call is successful when made from the main thread of my I need to do differently to get this to work properly? C# Discussions System.Reflection.BindingFlags.InvokeMethod (1) System.Reflection.BindingFlags.Default (1) Thread.CurrentThread.SetApartmentState (1) WMPrintEmailDDE (1) ParameterizedThreadStart (1) Marshal word instance through a proxy _wordApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default System.Reflection.BindingFlags.InvokeMethod, null, _wordApp, new object[] {"SomeMacro"}); }); t.IsBackground = true; t.Start(); . . . Willy. After further thinking, I list) { argumentList[counter] = current; counter++; } _wordApp.GetType().InvokeMember("Run", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, _wordApp, argumentList); } The apartment state is irrelevant here, the COM object is an out