I am attempting to put a combo box into a datagrid, I have created
a component class called DataGridComboBo xColumn.cs
*/ I keep getting these 2 errors when I run the project :
1)Object reference not set to an instance of the object AND
2)dgcbcProducts = null*/
The same applies to the other objects daProducts, dsProducts, dgtsProducts,
dgtbcProduts - they are all underlined
in blue saying that they will have a default value of null as they are never
assigned to.
Making them public gets rid of the blue line
This is probably a simple question - but, the answer will stand me in good
stead.
---------------This is the windows form project code
-------------------------------
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
namespace DatagridComboBo xColumn
{
public class frmproducts : System.Windows. Forms.Form
{
private System.Windows. Forms.DataGrid dgproducts;
private System.Windows. Forms.Button btnSubmit;
private System.Data.Sql Client.SqlComma nd
sqlSelectComman d1;
private System.Data.Sql Client.SqlComma nd sqlInsertComman d1;
private System.Data.Sql Client.SqlComma nd sqlUpdateComman d1;
private System.Data.Sql Client.SqlComma nd sqlDeleteComman d1;
private System.Data.Sql Client.SqlDataA dapter sqlDataAdapter1 ;
public System.Windows. Forms.DataGridT ableStyle dgtsproducts;
public System.Windows. Forms.DataGridT extBoxColumn dgtbcProducts;
public System.Windows. Forms.DataGridT ableStyle dgtsProducts;
public DataGridComboBo xColumn dgcbcProducts;
public System.Data.Sql Client.SqlDataA dapter daProducts;
public System.Data.Dat aSet dsProducts;
private System.Componen tModel.Containe r components = null;
public frmproducts()
{
InitializeCompo nent();
//Set datagrid preferred height to comboboxheight
dgproducts.Pref erredRowHeight = dgcbcProducts.C ombobox.Height + 1;
//dgcbcProducts is the problem object
}
a component class called DataGridComboBo xColumn.cs
*/ I keep getting these 2 errors when I run the project :
1)Object reference not set to an instance of the object AND
2)dgcbcProducts = null*/
The same applies to the other objects daProducts, dsProducts, dgtsProducts,
dgtbcProduts - they are all underlined
in blue saying that they will have a default value of null as they are never
assigned to.
Making them public gets rid of the blue line
This is probably a simple question - but, the answer will stand me in good
stead.
---------------This is the windows form project code
-------------------------------
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
namespace DatagridComboBo xColumn
{
public class frmproducts : System.Windows. Forms.Form
{
private System.Windows. Forms.DataGrid dgproducts;
private System.Windows. Forms.Button btnSubmit;
private System.Data.Sql Client.SqlComma nd
sqlSelectComman d1;
private System.Data.Sql Client.SqlComma nd sqlInsertComman d1;
private System.Data.Sql Client.SqlComma nd sqlUpdateComman d1;
private System.Data.Sql Client.SqlComma nd sqlDeleteComman d1;
private System.Data.Sql Client.SqlDataA dapter sqlDataAdapter1 ;
public System.Windows. Forms.DataGridT ableStyle dgtsproducts;
public System.Windows. Forms.DataGridT extBoxColumn dgtbcProducts;
public System.Windows. Forms.DataGridT ableStyle dgtsProducts;
public DataGridComboBo xColumn dgcbcProducts;
public System.Data.Sql Client.SqlDataA dapter daProducts;
public System.Data.Dat aSet dsProducts;
private System.Componen tModel.Containe r components = null;
public frmproducts()
{
InitializeCompo nent();
//Set datagrid preferred height to comboboxheight
dgproducts.Pref erredRowHeight = dgcbcProducts.C ombobox.Height + 1;
//dgcbcProducts is the problem object
}
Comment