之后怎么在主窗体实现这个方法啊 实现的方法要把查到的数据显示在主窗体的datagridview上面
解决方案 »
- 求助:如何利用smtp协议接收邮件?
- c# winform中webbrowser中层加载问题
- 做系统的时候,数据库里直接存图片,还是数据库只存图片路径,然后根据路径找到相应的图片?各有什么好出啊?
- 请教.NET下是如何实现AOP编程的?
- PlaySound()如何调用
- 异步Socket Server端 Client端,已经做成Winform 的Control要的留个mail
- 将水晶报表导出为excel,代码调试没有问题,但是发布后,在firefox导出的格式变成.aspx
- 各位前辈,急求水晶报表打印机CODE128的方法
- sqlserver中decimal(38)怎么把最大值读出来
- 各位帅哥美女谁有vs.net中文版的产品密匙?急ing !在线等!
- 线程中suspend不工作
- char * 如何使用
父窗体form1子窗体form2
form1打开form2:Form2 frm2 = new Form2();frm2.Owner=this;frm2.show();
子窗体调父窗体方法:form2 Form1 frm1;frm1 = (Form1)
this.Ownerfrm1.更新datagridview(参数是frm2查询的结果)
form1打开form2之前,一定会先给form2传参数,这些参数可以在form2中定义成public型
然后用form2.showdialog()的方式打开form2,这样在form2关闭之前,主窗体代码不再继续执行,而是等待form2关闭。
form2关闭的时候,关闭按钮中写代码,保存查询选择内容
然后form1继续执行showdialog之后的代码,你可以在这里获取form2的选择内容并查询
private void button1_MouseMove(object sender, MouseEventArgs e)
{
button1.ImageAlign = ContentAlignment.MiddleLeft;//鼠标移动到button1时改变图片位置
}
private void button2_MouseMove(object sender, MouseEventArgs e)
{
button2.ImageAlign = ContentAlignment.MiddleLeft;//鼠标移动到button2时改变图片位置
}
private void button3_MouseMove(object sender, MouseEventArgs e)
{
button3.ImageAlign = ContentAlignment.MiddleLeft;//鼠标移动到button3时改变图片位置
}
private void button4_MouseMove(object sender, MouseEventArgs e)
{
button4.ImageAlign = ContentAlignment.MiddleLeft;//鼠标移动到button4时改变图片位置
}
private void button5_MouseMove(object sender, MouseEventArgs e)
{
button5.ImageAlign = ContentAlignment.MiddleLeft;//鼠标移动到button5时改变图片位置
}
private void button1_MouseLeave(object sender, EventArgs e)
{
button1.ImageAlign = ContentAlignment.MiddleCenter;//鼠标移动到button1时改变图片位置
}
private void button2_MouseLeave(object sender, EventArgs e)
{
button2.ImageAlign = ContentAlignment.MiddleCenter;//鼠标离开时改变button2图片位置
}
private void button3_MouseLeave(object sender, EventArgs e)
{
button3.ImageAlign = ContentAlignment.MiddleCenter;//鼠标离开时改变button3图片位置
}
private void button4_MouseLeave(object sender, EventArgs e)
{
button4.ImageAlign = ContentAlignment.MiddleCenter;//鼠标离开时改变button4图片位置
}
private void button5_MouseLeave(object sender, EventArgs e)
{
button5.ImageAlign = ContentAlignment.MiddleCenter;//鼠标离开时改变button5图片位置
}
private void button6_MouseMove(object sender, MouseEventArgs e)
{
button6.ImageAlign = ContentAlignment.MiddleLeft;//鼠标移动到button6时改变图片位置
}
private void button6_MouseLeave(object sender, EventArgs e)
{
button6.ImageAlign = ContentAlignment.MiddleCenter;//鼠标离开时改变button6图片位置
}
void BabyWindow_UpdateDataGridView(object sender,EventArgs e)
{
if(Frm_Child.GlobalFlag == false) //当单击删除按钮时
{
if(ConnPubs.State == ConnectionState.Closed) //当数据库处于断开状态时
{
ConnPubs.Open(); //打开数据库的连接
}
string AfreshString = "delete tb_User where userID=" + Frm_Child.DeleteID.Trim();//定义一个删除数据的字符串
PersonalInformation = new SqlCommand(AfreshString,ConnPubs); //执行删除数据库字段
PersonalInformation.ExecuteNonQuery(); //执行SQL语句并返回受影响的行数
ConnPubs.Close(); //关闭数据库
DisplayData(); //显示数据库更新后的内容
MessageBox.Show("数据删除成功!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);//弹出删除数据成功的提示
}
else
{
if(ConnPubs.State == ConnectionState.Closed) //当数据库处于关闭状态时
{
ConnPubs.Open(); //打开数据库
}
string InsertString = "insert into tb_User values('" + Frm_Child.idContent + "','" + Frm_Child.nameContent + "','" + Frm_Child.phoneContent + "','" + Frm_Child.addressContent + "')";//定义一个插入数据的字符串变量
PersonalInformation = new SqlCommand(InsertString,ConnPubs);//执行插入数据库字段
PersonalInformation.ExecuteNonQuery();//执行SQL语句并返回受影响的行数
ConnPubs.Close(); //关闭数据库
DisplayData(); //显示更新后的数据
MessageBox.Show("数据添加成功!","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Asterisk);//弹出添加成功的提示信息
}//节选CodeGo.net/