1.使网格dataGridView的某一列显示特殊颜色,以突显某一列展示给用户:
this.dataGridView1.Columns[7].DefaultCellStyle.BackColor = Color.Yellow;
如果不确定列的索引,也可以用这种方式: this.dataGridView1.Columns["DQKCL"].DefaultCellStyle.BackColor = Color.Salmon;
2.网格dataGridView中按钮单击事件:
//到款信息的按钮事件
private void dataGridViewToAccountInfo_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
try
{
if (e.ColumnIndex == 2)//dataGridView列的索引
{
BillingSystem.LoadingUnloadingContract_Show LoadingUnloadingContract_ShowForm = new LoadingUnloadingContract_Show();//创建窗体
LoadingUnloadingContract_ShowForm.StartPosition = FormStartPosition.CenterParent;
LoadingUnloadingContract_ShowForm.ShowDialog();
}
}
catch (Exception ex)
{
}
3.取得网格dataGridView一行数据:
string RKDBH = this.dataGridView1.SelectedRows[0].Cells["RKDBH"].Value.ToString();//入库单编号
s