如何解决如何在Datagridview中汇总数据
-
我已经尝试在Datagridview 1中合并数据列 我想总结第3列,第4列和第5列的数据 关于合并第0列,第1列,请帮助我总结一下 Datagridview中的行 -我的输出是Hsn Gst应征税金额cgstamt sgstamt
8397 10.00 10000 500 500 8397 10.00 20000 1000 1000
-
我想要结果 Hsn Gst%应征税金额amt cgstamt sgstamt 8397 10 30000 1500 1500
-
这是我用于合并数据的代码
私有Sub DataGridView2_CellPainting(作为对象发送,作为As
DataGridViewCellPaintingEventArgs)句柄 DataGridView2.CellPainting 如果e.ColumnIndex = 0并且e.RowIndex -1然后 使用gridBrush作为Brush =新的SolidBrush(Me.DataGridView2.GridColor),backColorBrush作为Brush = 新 使用gridLinePen作为笔=新笔(gridBrush) e.Graphics.FillRectangle(backColorBrush,e.CellBounds)If e.RowIndex < DataGridView2.Rows.Count - 2 AndAlso DataGridView1.Rows(e.RowIndex + 1).Cells(e.ColumnIndex).Value.ToString() <> e.Value.ToString() Then e.Graphics.DrawLine(gridLinePen,e.CellBounds.Left,e.CellBounds.Bottom - 1,e.CellBounds.Right - 1,
e.CellBounds.Bottom-1) 万一 e.Graphics.DrawLine(gridLinePen,e.CellBounds.Right-1,e.CellBounds.Top,e.CellBounds.Right-1,
e.CellBounds.Bottom)If Not e.Value Is Nothing Then If e.RowIndex > 0 AndAlso DataGridView2.Rows(e.RowIndex - 1).Cells(e.ColumnIndex).Value.ToString() = e.Value.ToString() Then Else e.Graphics.DrawString(CType(e.Value,String),e.CellStyle.Font,
Brushes.Black,e.CellBounds.X + 2,
e.CellBounds.Y + 5,StringFormat.GenericDefault) 万一 如果结束e.Handled = True End Using End Using End If If e.ColumnIndex = 1 AndAlso e.RowIndex <> -1 Then Using gridBrush As Brush = New SolidBrush(Me.DataGridView2.GridColor),backColorBrush As Brush = New SolidBrush(e.CellStyle.BackColor) Using gridLinePen As Pen = New Pen(gridBrush) e.Graphics.FillRectangle(backColorBrush,e.CellBounds) If e.RowIndex < DataGridView2.Rows.Count - 2 AndAlso DataGridView1.Rows(e.RowIndex + 1).Cells(e.ColumnIndex).Value.ToString() <> e.Value.ToString() Then e.Graphics.DrawLine(gridLinePen,e.CellBounds.Bottom - 1) End If e.Graphics.DrawLine(gridLinePen,e.CellBounds.Top,e.CellBounds.Bottom) If Not e.Value Is Nothing Then If e.RowIndex > 0 AndAlso DataGridView2.Rows(e.RowIndex - 1).Cells(e.ColumnIndex).Value.ToString() = e.Value.ToString() Then Else e.Graphics.DrawString(CType(e.Value,
Brushes.Black,e.CellBounds.X + 2,
e.CellBounds.Y + 5,StringFormat.GenericDefault) 万一 如果结束e.Handled = True End Using End Using End If If e.ColumnIndex = 4 AndAlso e.RowIndex <> -1 Then Using gridBrush As Brush = New SolidBrush(Me.DataGridView2.GridColor),e.CellBounds.Bottom - 1) End If e.Graphics.DrawLine(gridLinePen,
Brushes.Black,e.CellBounds.X + 2,
e.CellBounds.Y + 5,StringFormat.GenericDefault) 万一 如果结束e.Handled = True End Using End Using End If If e.ColumnIndex = 2 AndAlso e.RowIndex <> -1 Then Using gridBrush As Brush = New SolidBrush(Me.DataGridView2.GridColor),e.CellBounds) If e.RowIndex < DataGridView2.Rows.Count - 2 AndAlso DataGridView1.Rows(e.RowIndex + 1).Cells(e.ColumnIndex).Value.ToString() <> e.Value.ToString() Then e.Graphics.DrawLine(gridLinePen,e.CellBounds.Bottom) If Not e.Value Is Nothing Then If e.RowIndex > 0 AndAlso DataGridView2.Rows(e.RowIndex - 1).Cells(e.ColumnIndex).Value.ToString() = e.Value.ToString() Then Else e.Graphics.DrawString(CType(e.Value,
Brushes.Black,e.CellBounds.X + 2,
e.CellBounds.Y + 5,StringFormat.GenericDefault) 万一 如果结束e.Handled = True End Using End Using End If End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。