ので、その紹介をさせていただきます。(It is more probable than not that PropertyGrid should use this method for its purpose!)
以下のテストプログラムはPropertyGridのメンバーを総て拾って表示します。
【TestGetMembers.cs】
//////////////////////////////
// TestGetMembers.cs
// Check the members of Object
//////////////////////////////
using System;
using System.Windows.Forms;
using System.Reflection; //GetMembersメソッドを使う為に必要
namespace TestGetMembers
{
public class Sample
{
public static void Main()
{ //PropertyGridクラスのTypeを指定する
Type t = typeof(System.Windows.Forms.PropertyGrid); //PropertyGridクラスのType tのメンバー情報を取得する /* BindingFlags
メンバ名 説明(値)
Public パブリックメンバを検索の対象に加える。(16)
NonPublic パブリックでないメンバを検索の対象に加える。(32)
Instance 非静的メンバ(インスタンスメンバ)を検索の対象に加える。(4)
Static 静的メンバを検索の対象に加える。(8)
DeclaredOnly 継承されたメンバを検索の対象にしない。(2)
FlattenHierarchy 階層構造の上位の静的メンバを検索の対象に加える。(64)
*/
MemberInfo[] members = t.GetMembers(BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.Static |
BindingFlags.DeclaredOnly);
foreach (MemberInfo m in members)
{ //メンバーの型と名前を表示する
Console.WriteLine("{0} - {1}", m.MemberType, m.Name);
}
Console.Read();
}
}
}
/////////////////////
//C# PropertyGrid.cs
/////////////////////
using System;
using System.IO; //FileInfoオブジェクト取得の為
using System.Windows.Forms;
using System.Drawing;
namespace PropertyGridTest
{
public partial class App : Form
{ //解説:メンバーコントロールです。
PropertyGrid propGrid;
Button exitBtn;
[STAThread] //解説:エントリーポイントです。
public static void Main()
{
Application.Run(new App());
}
// Sets myListView to the groups created for the specified column.
private void SetGroups(int column)
{ // Remove the current groups.
myListView.Groups.Clear();
// Retrieve the hash table corresponding to the column.
Hashtable groups = (Hashtable)groupTables[column];
// Copy the groups for the column to an array.
ListViewGroup[] groupsArray = new ListViewGroup[groups.Count]; //解説:ここからが私の追加部分 foreach(ListViewGroup group in groupsArray)
group.CollapsedState = ListViewGroupCollapsedState.Collapsed;
//解説:または
for(int i = 0; i < groups.Count; i++)
groupsArray[i].CollapsedState = ListViewGroupCollapsedState.Collapsed; ・
いずれにせよ、Microsoft帝国の高価な開発ツール(上記↑1.参照)を買うことを拒否しながらも、WYSWYGベースのIDEに当時から執着していたことが判りますが(それが翌2002年にフリーのBCCで"BCC Form and BCCSkelton"を開発する動機にもなりましたが)、このEditWinにも現在のWindows 11の環境で動くものがあります。それらはWindows SDKベースで書き、BCCでコンパイルした、