Reputation: 533
I have a GridView in my form and I want when I click on a button to open another form and fill it with informations from the selected row in the GridView.
This is the code I tried in the form that contains the 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
}
}
}
And this is the code I tried in that other form:
public ModifierCollection(String getKeyWordCollectionName, String getKeyWordEditeurName)
{
collectionBox.Text = String.IsNullOrEmpty(getKeyWordCollectionName) ?
"unknown" :
getKeyWordCollectionName;
editeurBox.Text = String.IsNullOrEmpty(getKeyWordEditeurName) ?
"unknown" :
getKeyWordEditeurName;
InitializeComponent();
}
But it gives me an error in this line: collectionBox.Text = getKeyWordCollectionName;
Object reference not set to an instance of an object.
Upvotes: 0
Views: 187
Reputation: 11635
Most likely your collectionBox
isn't created. Try to move it after InitializeComponent()
Upvotes: 2