사용자 지정 컬렉션 편집기가 있고 프로그래밍 방식으로 목록 (컬렉션)에 항목을 추가하여 목록 상자에 표시되도록 할 수 있습니다. 내가 어떻게 할 수 있니? CollectionEditor의 AddItems 메서드에 대해 알고 있지만 컬렉션 개체를 매개 변수로 사용하지만 CollectionEditor의 내부 목록 개체를 가져 오는 방법을 찾을 수 없습니다./프로그래밍 방식으로 CollectionEditor의 list/listbox/collection에 항목을 추가하는 방법은 무엇입니까? [수정 된]
[업데이트] 적절한 메서드 이름은입니다. 'SetItems' [/ 업데이트]
[업데이트 2] 내가 할 노력하고있어의 소스 코드 ...
public class MyCollectionEditor : CollectionEditor
{
private Type m_itemType = null;
public MyCollectionEditor(Type type)
: base(type)
{
m_itemType = type;
}
protected override CollectionForm CreateCollectionForm()
{
Button buttonLoadItem = new Button();
buttonLoadItem.Text = "Load from DB";
buttonLoadItem.Click += new EventHandler(ButtonLoadItem_Click);
m_collectionForm = base.CreateCollectionForm();
TableLayoutPanel panel1 = m_collectionForm.Controls[0] as TableLayoutPanel;
TableLayoutPanel panel2 = panel1.Controls[1] as TableLayoutPanel;
panel2.Controls.Add(buttonLoadItem);
return m_collectionForm;
}
private void ButtonLoadItem_Click(object sender, EventArgs e)
{
if (m_itemType.Equals(typeof(MyCustomCollection)))
{
MyCustomItem item = ...load from DB...
//definition: SetItems(object editValue, object[] value);
SetItems(-> what goes here?! <- , new object[] { item });
}
}
}
[/ 업데이트 2] 내가
을 오해 할 수있다
+1 자신의 솔루션을 완전히 설명하는 업데이트를 게시합니다. 이제는 저에게 효과가 있는지 알게 될 것입니다 ...;) – IAbstract