Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:32:41+00:00 2026-06-17T22:32:41+00:00

I am importing a sheet from Excel. I need to add a new cell

  • 0

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..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:32:41+00:00Added an answer on June 17, 2026 at 10:32 pm

    I suggest you to use XtraGrid Unbound Columns, where you can write your custom text.

    Example code snippet to add UnBound Column to Xtragrid:

    using DevExpress.XtraGrid.Views.Base;
    using DevExpress.XtraGrid.Columns;
    
    private void Form1_Load(object sender, System.EventArgs e) {
       // ...
       gridControl1.ForceInitialize();
    
       // Create an unbound column.
       GridColumn unbColumn = gridView1.Columns.AddField("Total");
       unbColumn.VisibleIndex = gridView1.Columns.Count;
       unbColumn.UnboundType = DevExpress.Data.UnboundColumnType.Decimal;
       // Disable editing.
       unbColumn.OptionsColumn.AllowEdit = false;
       // Specify format settings.
       unbColumn.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
       unbColumn.DisplayFormat.FormatString = "c";
       // Customize the appearance settings.
       unbColumn.AppearanceCell.BackColor = Color.LemonChiffon;
    }
    
    // Returns the total amount for a specific row.
    decimal getTotalValue(int listSourceRowIndex) {
        DataRow row = nwindDataSet.Tables["Order Details"].Rows[listSourceRowIndex];
        decimal unitPrice = Convert.ToDecimal(row["UnitPrice"]);
        decimal quantity = Convert.ToDecimal(row["Quantity"]);
        decimal discount = Convert.ToDecimal(row["Discount"]);
        return unitPrice * quantity * (1 - discount);
    }
    
    // Provides data for the Total column.
    private void gridView1_CustomUnboundColumnData(object sender, CustomColumnDataEventArgs e) {
       if (e.Column.FieldName == "Total" && e.IsGetData) e.Value = 
         getTotalValue(e.ListSourceRowIndex);
    }
    

    or you can use CustomColumnDisplayText event to display custom text Xtragrid.

    using DevExpress.XtraGrid.Views.Base;
    
        private void gridView1_CustomColumnDisplayText(object sender, 
        CustomColumnDisplayTextEventArgs e) {
           if(e.Column.FieldName == "Discount")
              if(Convert.ToDecimal(e.Value) == 0) e.DisplayText = "";
        }
    

    To know that how create Columns and Binding Them to Data Fields, refer documentation:

    Overview of Columns and Card Fields

    using DevExpress.XtraGrid.Views.Base;
    
    ColumnView View = gridControl1.MainView as ColumnView;
    DialogResult answer = MessageBox.Show("Do you want to create columns for all fields?", 
      "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
    if (answer == DialogResult.Yes)
       View.PopulateColumns();
    else {
       string[] fieldNames = new string[] {"ProductID", "ProductName", "QuantityPerUnit", "UnitPrice"};
       DevExpress.XtraGrid.Columns.GridColumn column;
       View.Columns.Clear();
       for (int i = 0; i < fieldNames.Length; i++) {
          column = View.Columns.AddField(fieldNames[i]);
          column.VisibleIndex = i;
       }
    }
    

    Hope this help..

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am importing Excel sheet into DataGridView.I have one of the cell has date
I have an excel spread sheet (well, hundreds of them) which I need importing
I'm importing data from an Excel sheet on to a DataTable using the following
i am preparing myself for importing data from excel sheet to sql server 2005.I
i am currently working on importing data from excel sheet to sql server.i have
I am working on importing data from an Excel sheet to database. The Excel
I am importing an excel sheet into my sql database. Everything works fine, but
I have an excel sheet that I am importing but I would like some
i am importing data from excel to sqlserver..i have filled the dataset with the
This is the entire code that goes from importing an Excel document to creating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.