我只知道 如何设置 所有单元格的样式的方法: DataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.Single我在datagridview中加入一个button列,点击它 就会设置该列第2个一个单元格的样式,如何做到呢?
private void dataviewAccountList_CellContentClick(object sender, DataGridViewCellEventArgs e)
//点击投资者列表中 内容时发生
{
//如果"编辑"列按钮被点击
if (dataviewAccountList.Columns[e.ColumnIndex].Name == "btnEdit") //判断是否单击了“编辑”列
{
dataviewAccountList[1, e.RowIndex].Style = DataGridViewCellBorderStyle.Raised;//报错了!!!
}
}还有一个小问题:在我点击某一行的btnEdit后,要想使其他行的btnEdit不能点击,这功能如何实现?
谢谢!!!
private void dataviewAccountList_CellContentClick(object sender, DataGridViewCellEventArgs e)
//点击投资者列表中 内容时发生
{
//如果"编辑"列按钮被点击
if (dataviewAccountList.Columns[e.ColumnIndex].Name == "btnEdit") //判断是否单击了“编辑”列
{
dataviewAccountList[1, e.RowIndex].Style = DataGridViewCellBorderStyle.Raised;//报错了!!!
}
}还有一个小问题:在我点击某一行的btnEdit后,要想使其他行的btnEdit不能点击,这功能如何实现?
谢谢!!!
如spread控件
{
if (e.RowIndex > -1)
{
if (e.ColumnIndex == 0)//所在列的索引
{
DataGridViewCellStyle newCellStyle = new DataGridViewCellStyle();
dataGridView1.Rows[e.RowIndex].DefaultCellStyle = newCellStyle; }
}
}
{
DataGridViewCellStyle newCellStyle = new DataGridViewCellStyle();
dataGridView1.Rows[e.RowIndex].DefaultCellStyle = newCellStyle;