0

我的表单中有一个 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;

你调用的对象是空的。

4

2 回答 2

2

很可能您collectionBox没有创建。尝试移动后InitializeComponent()

于 2012-09-30T15:38:51.747 回答
0

在 datagridviewRow 的 Cell 中使用 Value 属性

于 2012-09-30T14:58:43.860 回答