我的表单中有一个 GridView,当我单击一个按钮打开另一个表单并用 GridView 中选定行的信息填充它时,我想要。
这是我在包含 GridView 的表单中尝试的代码:
private void barButtonItem13_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
{
DataRow getRow = gridView1.GetDataRow(gridView1.GetSelectedRows()[0]);
using (Collections_.ModifierCollection modifierCollection = new Collections_.ModifierCollection((string)getRow[1],(string)getRow[2]))
{
var result = modifierCollection.ShowDialog();
if (result == DialogResult.OK)
{
// Just some code that I used
}
}
}
这是我以其他形式尝试过的代码:
public ModifierCollection(String getKeyWordCollectionName, String getKeyWordEditeurName)
{
collectionBox.Text = String.IsNullOrEmpty(getKeyWordCollectionName) ?
"unknown" :
getKeyWordCollectionName;
editeurBox.Text = String.IsNullOrEmpty(getKeyWordEditeurName) ?
"unknown" :
getKeyWordEditeurName;
InitializeComponent();
}
但它在这一行给了我一个错误:collectionBox.Text = getKeyWordCollectionName;
你调用的对象是空的。