简体   繁体   中英

C# how to display DataGridView column header into textbox?

当我在DataGridView中选择特定的单元格时,如何在文本框中显示列标题?

Try this:

int idx = this.dataGridView1.SelectedCells[0].ColumnIndex;
this.textBox1.Text = this.dataGridView1.Columns[idx].HeaderText;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM