没有合适的资源?快使用搜索试试~ 我知道了~
DataGridView合并单元格
需积分: 45 1 下载量 13 浏览量
2016-04-19
13:13:48
上传
评论
收藏 6KB TXT 举报
温馨提示
试读
5页
DataGridView合并单元格
资源推荐
资源详情
资源评论
#region"合并单元格(纵向合并及横向合并)"
private int? nextrow = null;
private int? nextcol = null;
private void dataGridView1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
if (this.dataGridView1.Columns["description"].Index == e.ColumnIndex && e.RowIndex >= 0)
{
if (this.nextcol != null & e.ColumnIndex == this.nextcol)
{
e.CellStyle.BackColor = Color.LightBlue;
this.nextcol = null;
}
if (this.nextrow != null & e.RowIndex == nextrow)
{
e.CellStyle.BackColor = Color.LightPink;
this.nextrow = null;
}
if (e.RowIndex != this.dataGridView1.RowCount - 1)
{
if (e.Value.ToString() == this.dataGridView1.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value.ToString())
{
e.CellStyle.BackColor = Color.LightPink;
nextrow = e.RowIndex + 1;
}
}
}
if (this.dataGridView1.Columns["name"].Index == e.ColumnIndex && e.RowIndex >= 0)
{
if (e.Value.ToString() == this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString())
private int? nextrow = null;
private int? nextcol = null;
private void dataGridView1_CellFormatting(object sender, System.Windows.Forms.DataGridViewCellFormattingEventArgs e)
{
if (this.dataGridView1.Columns["description"].Index == e.ColumnIndex && e.RowIndex >= 0)
{
if (this.nextcol != null & e.ColumnIndex == this.nextcol)
{
e.CellStyle.BackColor = Color.LightBlue;
this.nextcol = null;
}
if (this.nextrow != null & e.RowIndex == nextrow)
{
e.CellStyle.BackColor = Color.LightPink;
this.nextrow = null;
}
if (e.RowIndex != this.dataGridView1.RowCount - 1)
{
if (e.Value.ToString() == this.dataGridView1.Rows[e.RowIndex + 1].Cells[e.ColumnIndex].Value.ToString())
{
e.CellStyle.BackColor = Color.LightPink;
nextrow = e.RowIndex + 1;
}
}
}
if (this.dataGridView1.Columns["name"].Index == e.ColumnIndex && e.RowIndex >= 0)
{
if (e.Value.ToString() == this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString())
资源评论
qmh80
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功