hi! how can i get the column name of the current cell in the radgridview?
RadGridView1 is the name of my datagrid.
these doesn't work:


help me please...

Recommended Answers

All 4 Replies

Try something like this:

string str = dataGridView1.Columns[0].HeaderText;

Hi, to add to ddanbe`s post.
You can do it this way too:

foreach (DataGridViewRow row in dataGridView1.Rows)
                foreach (DataGridViewCell cell in row.Cells)
                 //CELL here does not have a property of HeaderText.
                    //so you can do it like ddanbe showed or:
                    string header = dataGridView1.Columns[cell.ColumnIndex].HeaderText;

thanks for your suggestion. but it doesn't work. here's the error:

Telerik.Windows.Controls.GridViewColumn does not contain a definition for HeaderText

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.