C# DataGridView属性设置
1. 设置行高
dataGridView1.RowTemplate.Height = 38;
2. 取消排序功能
foreach (DataGridViewColumn dataGridViewColumn in dataGridView1.Columns)
dataGridViewColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
3. 获取DataGridView指定位置的值
//返回类型为object
dataGridView1[columnIndex, rowIndex].Value
4. DataGridView 取消默认选中行
为DataGridView
添加绑定完成事件dataGridView1.DataBindingComplete += DataGridView_DataBindingComplete;
private void DataGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
{
var dataGridView = sender as DataGridView;
if (dataGridView != null)
dataGridView.ClearSelection();
}