C# 如何让两个窗体使用同一个变量的值 我在from1中定义了变量rows并且通过操作给rows赋了值那我如何在from2中得到这个变量rows的值???在线等,哪为大哥知道啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 定义成静态的就可以了,static,或者你将这个变量作为form2的构造函数的参数 ref:http://blog.csdn.net/knight94/archive/2006/03/18/628285.aspx 把你的这个rows定义成public static就可以了 大哥哥我是新手,可以给个例子吗?这里的rows是表里的IDrows=myDataGrid[myDataGrid.CurrentRowIndex,0];//将DataGrid中当前点击行的ID给rows我想要在from2中得到这个ID怎么做啊??? To use static is not a correct way here ref:http://blog.csdn.net/zhzuo/archive/2004/04/05/22027.aspx 你的文章我看了,不过你是怎么用this的把第2个窗体弄出来的啊我是在工程里添加的from2from2 myfrom2 = new from2 () ;myfrom2.show();我是这样show的然后在from2中我重载了from2写了个构造函数,用 this.变量 的方法,但是报错啊 方法很多,试试用类的方法,在页面中添加类 //元素设置为静态public class xxx{private static int x;private static string y;private static bool z; ……………………………………public static int x{get{return _x;}set{_x= value;}} public static string y{get{_y;}set{_y= value;}}public static bool z{get{return _z;}set{_z= value;}} ……………………………………………………}其他窗体调用xxx.x =1;m = xxx.x; .net/c#如何解析.xml文件 怎么获取本地网卡发送数据速度 winform 下Panel 赋值 利用反射载入的窗体怎么传参? Winform DataGrid 列头如何禁用排序 c#如何实现一个接口,里面包含EVENT? 正则 如何将数字前面的0替换掉? 马上给分 有没有谁知道那里关于算法的知识啊? 怎样清空存放文件路径的数组? 发送邮件问题??? 如何用C#创建基于Windows CE的手机程序远程访问Oracle数据库? 请教一个简单的正则表达式问题,用于html解析
http://blog.csdn.net/knight94/archive/2006/03/18/628285.aspx
这里的rows是表里的ID
rows=myDataGrid[myDataGrid.CurrentRowIndex,0];//将DataGrid中当前点击行的ID给rows
我想要在from2中得到这个ID
怎么做啊???
http://blog.csdn.net/zhzuo/archive/2004/04/05/22027.aspx
我是在工程里添加的from2
from2 myfrom2 = new from2 () ;
myfrom2.show();
我是这样show的
然后在from2中我重载了from2写了个构造函数,用 this.变量 的方法,但是报错啊
public class xxx
{
private static int x;
private static string y;
private static bool z;
……………………………………
public static int x
{
get{return _x;}
set{_x= value;}
}
public static string y
{
get{_y;}
set{_y= value;}
}
public static bool z
{
get{return _z;}
set{_z= value;}
}
……………………………………………………
}
其他窗体调用
xxx.x =1;
m = xxx.x;