winform中点击弹出已有的form

.Net技术 码拜 8年前 (2016-06-06) 1016次浏览
是这样,本人要点击datagridview里的某一条记录,然后弹出窗口显示该记录的详细信息(datagridview里只有部分字段)。新的form已经添加在Forms里了,暂时叫Form1.cs,各路高手有什么办法没。
小弟之前试过
Form1 form = new Form1();
form.show();这招不行,直接报红了,说没有Form1的using的错误。
也试过
Form form = new Form();
form.show();这招虽然可以弹出窗口,但这个窗口里木有东西。
解决方案

25

本人是这样
private void ButGetCost_Click_1(object sender, EventArgs e)
{
if(dataGridView1.RowCount > 0)
{
int i = dataGridView1.SelectedCells[0].RowIndex;
string sendItemCode = dataGridView1.Rows[i].Cells[1].Value.ToString();
string sendItemName = dataGridView1.Rows[i].Cells[2].Value.ToString();
OnlineStockEnquiry_GetCost OSEGC = new OnlineStockEnquiry_GetCost(sendItemCode,sendItemName);
OSEGC.ShowDialog();   //要弹出的FORM
}
else
{
MessageBox.Show(“No record found,Please enter other value search!”, “Notice”, MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
}

15

Shift+Alt+F10,回车

10

在Form1 form = new Form1();的Form1上Shift+Alt+F10,回车

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明winform中点击弹出已有的form
喜欢 (0)
[1034331897@qq.com]
分享 (0)