首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么从一个类 读写窗体的控件

2012-05-12 
如何从一个类读写窗体的控件C# code/////form1.csusing Systemusing System.Collections.Genericusing S

如何从一个类 读写窗体的控件

C# code
/////form1.csusing System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication3{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();        }     }}


C# code
///class.csnamespace WindowsFormsApplication3{    class Class1    {        static public void test()        {            ////这里            Label lab = Form1.        }    }}



如何在 Class1 里 读写 Form1 中的控件属性 例如 lable 控件

请给出例子代码, 多谢

[解决办法]
Label lab = Form1,我看成Label lab = New Form1了

如果是传入的就需要传入参数了

static public void test(Form1 f)
{
////这里
f.Lable1.Text = "AAA";
}

如果是Form1调用这个函数就写 Class1.test(this);

热点排行