form2中添加一个属性,用于保存修改后的结果。
form1中取这个属性的值,更改SelectedItems中的项。
form1中取这个属性的值,更改SelectedItems中的项。
解决方案 »
- 求一SQL语句。。。。。。。
- 请问有什么开源的神经网络项目?.net能用的
- 帮忙看下分页这样写好不好?
- 安装VS2005后会自动安装SQL SERVER 2005,可是怎么用啊?
- "不显示子窗体form2但可在主窗体form1中实现form2.show()的等价代码”, "或者在form1中直接操作form2的窗体资源“
- 读取文件2(FTP下读取)
- DownloadFileAsync下载文件的问题
- 关于object类型的问题
- AVI and Text on it.
- 在C#里如何把FILETIME转换成指定格式的时间字符串?
- windows程序打包带(SQL2005和水晶报表一起打包)
- 酒店客房管理软件是CS好还是BS的好?
private void button1_Click(object sender, EventArgs e)
{
string ex1 = listView1.CheckedItems[0].Text;
string ex2 = listView1.CheckedItems[0].SubItems[1].Text;
string ex3 = listView1.CheckedItems[0].SubItems[2].Text;
Form2 frmEdit = new Form2(ex1,ex2,ex3);
frmEdit.ShowDialog(this);
}
Form2中:
private void button1_Click(object sender, EventArgs e)
{
string strconnection1 = "Integrated Security = SSPI;Database = users;Server = (local)";
SqlConnection connection1 = new SqlConnection(strconnection1);
connection1.Open();
SqlCommand cmd1 = connection1.CreateCommand();
cmd1.CommandText = "INSERT INTO [Usermanagement] VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox3.Text + "');
cmd1.Connection = connection1;
cmd1.CommandType = CommandType.Text;
int n = cmd1.ExecuteNonQuery();
connection1.Close();
this.Close();//关闭Form11
}
返回frmEdit.ShowDialog(this)的时候,数据库已经更新,但是listview里选中的checkbox那一项并没有更新……
private void button1_Click(object sender, EventArgs e)
{
Form2 frm = new Form2();
frm.form1 = this;
frm.Show();
}
//form2中
public Form1 form1;
private void button1_Click(object sender, EventArgs e)
{
form1.listView1.Items.Add(....);
}
http://topic.csdn.net/u/20100106/20/e9697297-75f9-4450-aaa9-da0da416cf41.html
public class Form2:Form
{
.... public string Text1
{//定义一个只读属性,返回textBox1的Text属性值,其他的TextBox可类似定义
get
{
return textBox1.Text;
}
}
}public class Form1:Form
{
..
private void button1_Click(object sender, EventArgs e)
{
string ex1 = listView1.CheckedItems[0].Text;
string ex2 = listView1.CheckedItems[0].SubItems[1].Text;
string ex3 = listView1.CheckedItems[0].SubItems[2].Text;
Form2 frmEdit = new Form2(ex1,ex2,ex3);
frmEdit.ShowDialog(this);
listView1.CheckItems[0].Text=frmEdit.Text1;//取Form2中定义的属性
...
}