C#怎么定义ListView为Public

2024-12-26 15:08:00
推荐回答(2个)
回答1:

用Control.Invoke()方法:

Form1里加上如下内容
public delegate void AddListItem(String myString);
public AddListItem myDelegate;

public Form1()
{
myDelegate = new AddListItem(AddListItemMethod);

}
public void AddListItemMethod(String myString)
{
myListBox.Items.Add(myString);
}

Test类加如下代码:

Form1 myForm;

public Test(Form1 form)
{
myForm = form;
}

public void CreateList()
{
myForm.Invoke(myFormControl1.myDelegate,new Object[] );
}

原理就是这样,具体实现你自已修改吧

回答2:

修改控件的Modifiers属性为Public