C# 如何将字符串从一个窗体发送到另一个窗体上的datagridview?
如何将字符串值从一个form2发送到主窗体上的C# 如何将字符串从一个窗体发送到另一个窗体上的datagridview?,c#,C#,如何将字符串值从一个form2发送到主窗体上的DataGridView1最后一行 实现这一点的简单方法是什么?您需要在窗口/窗体中使用一些属性。 大概是这样的: public class WinStringGen : *Window or Form* { ... string myStringValue = ""; private void save() { myStringValue = "value"; //set your value }
DataGridView1
最后一行
实现这一点的简单方法是什么?您需要在窗口/窗体中使用一些属性。 大概是这样的:
public class WinStringGen : *Window or Form*
{
...
string myStringValue = "";
private void save()
{
myStringValue = "value"; //set your value
}
public string MyStringValue
{
get{return myStringValue;}//Contains your string
}
...
}
WinStringGen win = new WinStringGen(); //init window
win.showDialog(); //open window. When this method is called, the code following it is not executed until after the dialog box is closed.
string myValue = win.MyStringValue; //get the value
现在您可以得到如下值:
public class WinStringGen : *Window or Form*
{
...
string myStringValue = "";
private void save()
{
myStringValue = "value"; //set your value
}
public string MyStringValue
{
get{return myStringValue;}//Contains your string
}
...
}
WinStringGen win = new WinStringGen(); //init window
win.showDialog(); //open window. When this method is called, the code following it is not executed until after the dialog box is closed.
string myValue = win.MyStringValue; //get the value
您可以在将调用form1的事件中使用此选项:
form1.datagridview1.rows[form1.datagridview1.rows.count-1].cells[0].value = mystring;
其中mystring
是要传递的字符串。有关更多信息,请发表评论。低质量问题。。。你试过什么?代码示例?