如何隐藏datagridview标头行 [英] how to hide datagridview header row
本文介绍了如何隐藏datagridview标头行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hai朋友,
下面的代码,用于选择datagridview行值到我的Windows窗体的文本框
Hai friends,
the below code for selecting datagridview rows value to textbox of my windows form
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
//if (dataGridView1.CurrentRow.Index == 0)
// {
// MessageBox.Show("please dont select Header columns");
// }
if (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString() == "Select")
{
//int index = dataGridView1.CurrentRow.Index;
textBox1.Text = dataGridView1.Rows[e.RowIndex].Cells["School_id"].Value.ToString();
textBox1.ReadOnly = true;
textBox2.Text = dataGridView1.Rows[e.RowIndex].Cells["School_name"].Value.ToString();
}
else
{
MessageBox.Show("please enter select button only");
}
}
}
这里的选择"是一个gridview按钮.
假设当我错误地单击datagridview的首行时,由于indexoutofboundexception会出现错误.请帮助停用此首行.
预先谢谢您
Here "select" is a gridview button.
suppose when i wrongly click the head row of datagridview the error would ocuur as indexoutofboundexception .please help to inactive this head row.
thank you in advance
推荐答案
请参阅以下 http://msdn.microsoft.com/zh-CN/library/2x16tybz.aspx [ ^ ].答案是:
See the following http://msdn.microsoft.com/en-us/library/2x16tybz.aspx[^]. The answer is:
dataGridView1.ColumnHeadersVisible = false;
这篇关于如何隐藏datagridview标头行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文