dataGridView1.ColumnHeadersDefaultCellStyle.Alignment=DataGridViewContentAlignment.MiddleCenter;//列标题居中 dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;//不换行 dataGridView1.Columns[0].Visible = false;//隐藏某一列 dataGridView1.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.False;//列标题不换行 for (int i = 0; i < dataGridView1.Rows.Count; i++) { dataGridView1.Rows[i].HeaderCell.Value = (i + 1).ToString();//给行头加序号 } for (int i = 0; i < dataGridView1.Columns.Count; i++) { dataGridView1.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;//适应表中内容 dataGridView1.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;//去掉排序三角形 } int id = dataGridView1.CurrentRow.Index; //获取用户选择了哪一行
DataGridView
最新推荐文章于 2022-03-04 16:18:52 发布