I am importing a sheet from Excel.
I need to add a new cell at the end of the grid containing messages about the empty cells where I saved them in an array called msg;
private void simpleButton1_Click(object sender, System.EventArgs e)
{
try
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=C:\\Users\\pc\\Documents\\Emp.xlsx;Extended Properties=\"Excel 12.0;HDR=Yes\"";
con.Open();
DataTable dtSchema;
dtSchema = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
OleDbCommand Command = new OleDbCommand ("select * FROM [" + dtSchema.Rows[0]["TABLE_NAME"].ToString() + "]", con);
OleDbDataAdapter da = new OleDbDataAdapter(Command);
DataSet ds = new DataSet ();
da.Fill(ds);
dataGrid1.DataSource = ds.Tables[0];
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
string[] msg = new string[50];
for (int i = 0; i < gridView3.RowCount ; i++)
{
System.Data.DataRow Rows = gridView3.GetDataRow(i);
string cellvalue = Rows[0].ToString();
if (cellvalue == "")
{
msg[0] = "Missing 'First Name'";
}
cellvalue = Rows[1].ToString();
if (cellvalue == "")
{
msg[1] = "Missing 'Father Name'";
}
cellvalue = Rows[2].ToString();
if (cellvalue == "")
{
msg[2] = "Missing 'Last Name'";
}
}
I am working with XtraGrid Control.. How Can I add this column a the add
Sorry I’m new to DevExpress
Thank You..
I suggest you to use XtraGrid Unbound Columns, where you can write your custom text.
Example code snippet to add UnBound Column to Xtragrid:
or you can use CustomColumnDisplayText event to display custom text Xtragrid.
To know that how create Columns and Binding Them to Data Fields, refer documentation:
Overview of Columns and Card Fields
Hope this help..