Usuário com melhor resposta
Correspondente ao MSHFlexGrid

Pergunta
-
Respostas
-
Crie uma classe, cole esse código e depois adicione na Toolbox e veja se lhe atende.
Public Class meuDataGridView Inherits DataGridView Protected Overloads Overrides Sub OnCellFormatting(ByVal args As DataGridViewCellFormattingEventArgs) ' Call home to base MyBase.OnCellFormatting(args) ' First row always displays If args.RowIndex = 0 Then Exit Sub End If If IsRepeatedCellValue(args.RowIndex, args.ColumnIndex) Then args.Value = String.Empty args.FormattingApplied = True End If End Sub Private Function IsRepeatedCellValue(ByVal rowIndex As Integer, ByVal colIndex As Integer) As Boolean Dim currCell As DataGridViewCell = Rows(rowIndex).Cells(colIndex) Dim prevCell As DataGridViewCell = Rows(rowIndex - 1).Cells(colIndex) If (currCell.Value = prevCell.Value) OrElse (currCell.Value IsNot Nothing AndAlso prevCell.Value IsNot Nothing AndAlso currCell.Value.ToString() = prevCell.Value.ToString()) Then Return True Else Return False End If End Function Protected Overloads Overrides Sub OnCellPainting(ByVal args As DataGridViewCellPaintingEventArgs) MyBase.OnCellPainting(args) args.AdvancedBorderStyle.Bottom = DataGridViewAdvancedCellBorderStyle.None ' Ignore column and row headers and first row If args.RowIndex < 1 OrElse args.ColumnIndex < 0 Then Exit Sub End If If IsRepeatedCellValue(args.RowIndex, args.ColumnIndex) Then args.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None Else args.AdvancedBorderStyle.Top = AdvancedCellBorderStyle.Top End If End Sub End Class
Att.,
Jeimes Ribeiro
- Editado Jeimes Ribeiro quinta-feira, 23 de agosto de 2012 20:16
- Marcado como Resposta MauricioBogo terça-feira, 28 de agosto de 2012 20:12
-
Clique com o botão direito do mouse na toolbox e depois clique em "choose items", após isso irá aparecer uma caixa e na aba ".NET Framework Components" procure pelo componente que você criou clicando em "browse...".
O componente criado deve estar na pasta do seu projeto em "debug".
Após isto, basta arrastar ele ao seu form.
Att.,
Jeimes Ribeiro
- Marcado como Resposta Harley AraujoModerator segunda-feira, 27 de agosto de 2012 14:37
Todas as Respostas
-
Crie uma classe, cole esse código e depois adicione na Toolbox e veja se lhe atende.
Public Class meuDataGridView Inherits DataGridView Protected Overloads Overrides Sub OnCellFormatting(ByVal args As DataGridViewCellFormattingEventArgs) ' Call home to base MyBase.OnCellFormatting(args) ' First row always displays If args.RowIndex = 0 Then Exit Sub End If If IsRepeatedCellValue(args.RowIndex, args.ColumnIndex) Then args.Value = String.Empty args.FormattingApplied = True End If End Sub Private Function IsRepeatedCellValue(ByVal rowIndex As Integer, ByVal colIndex As Integer) As Boolean Dim currCell As DataGridViewCell = Rows(rowIndex).Cells(colIndex) Dim prevCell As DataGridViewCell = Rows(rowIndex - 1).Cells(colIndex) If (currCell.Value = prevCell.Value) OrElse (currCell.Value IsNot Nothing AndAlso prevCell.Value IsNot Nothing AndAlso currCell.Value.ToString() = prevCell.Value.ToString()) Then Return True Else Return False End If End Function Protected Overloads Overrides Sub OnCellPainting(ByVal args As DataGridViewCellPaintingEventArgs) MyBase.OnCellPainting(args) args.AdvancedBorderStyle.Bottom = DataGridViewAdvancedCellBorderStyle.None ' Ignore column and row headers and first row If args.RowIndex < 1 OrElse args.ColumnIndex < 0 Then Exit Sub End If If IsRepeatedCellValue(args.RowIndex, args.ColumnIndex) Then args.AdvancedBorderStyle.Top = DataGridViewAdvancedCellBorderStyle.None Else args.AdvancedBorderStyle.Top = AdvancedCellBorderStyle.Top End If End Sub End Class
Att.,
Jeimes Ribeiro
- Editado Jeimes Ribeiro quinta-feira, 23 de agosto de 2012 20:16
- Marcado como Resposta MauricioBogo terça-feira, 28 de agosto de 2012 20:12
-
-
Clique com o botão direito do mouse na toolbox e depois clique em "choose items", após isso irá aparecer uma caixa e na aba ".NET Framework Components" procure pelo componente que você criou clicando em "browse...".
O componente criado deve estar na pasta do seu projeto em "debug".
Após isto, basta arrastar ele ao seu form.
Att.,
Jeimes Ribeiro
- Marcado como Resposta Harley AraujoModerator segunda-feira, 27 de agosto de 2012 14:37
-
-
-