我已使用自定义控件填充了flowLayoutPanel,并订阅了控件的MouseDown事件。如何创建EventArgs以评估自定义控件属性...
for(int i = 0; i < fileInfoArray.Length; i++)
{
myViewerArray[i] = new SubstanceViewer(fileInfoArray[i]);
myViewerArray[i].MouseDown += new MouseEventHandler(myViewerArray_MouseDown);
flowLayoutPanel1.Controls.Add(substanceViewerArray[i]);
}
所以我可以访问我的控件属性......
private void myViewerArray_MouseDown(object sender, MouseEventArgs e)
{
richTextBox1.Text = [myControl?].info
}
答案 0 :(得分:1)
访问sender
:
private void myViewerArray_MouseDown(object sender, MouseEventArgs e)
{
var myControl = sender as SubstanceViewer;
richTextBox1.Text = myControl.info;
}