实际的问题比较复杂,举个例子说吧.主程序有一个FORM,上面包含很多(一般会是30个以上的Button),在处理问题的时候需要把这些BUTTON存在一个LinkedList<Button> ButtonGroup=new LinkedList<Button>();中,在需要的时候调用ButtonGroup.ElementAt(i).Location返回特定的BUTTON的位置(也可以是其他属性)
但是我想把建立LinkedList的过程放在一个DLL文件中,然后主程序通过调用方法来访问,我想问一下怎么才能在一个DLL文件中访问到主程序FORM上的BUTTON控件,以便于把他加入到LinkedList中?或者有其他什么办法做到类似的功能.
但是我想把建立LinkedList的过程放在一个DLL文件中,然后主程序通过调用方法来访问,我想问一下怎么才能在一个DLL文件中访问到主程序FORM上的BUTTON控件,以便于把他加入到LinkedList中?或者有其他什么办法做到类似的功能.
需要这个培训视频的朋友请联系 QQ 936652114
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace ClassLibrary1
{
public class Class1
{
public List<Button> GetButton()
{
Button btn1 = new Button();
Button btn2 = new Button();
btn1.Text = "AA";
btn2.Text = "BB"; Point Point1 = new Point(100, 100);
btn1.Location = Point1; Point Point2 = new Point(0, 0);
btn2.Location = Point2; List<Button> listbtn = new List<Button>();
listbtn.Add(btn1);
listbtn.Add(btn2); return listbtn;
}
}
}
Form端代码private void Form1_Load(object sender, EventArgs e)
{
ClassLibrary1.Class1 cls = new ClassLibrary1.Class1();
foreach (Button btn in cls.GetButton())
{
Controls.Add(btn);
}
}