DataGridViewでセルのタイプをDataGridViewLinkCellにして利用した時に、選択状態の色が気に食わない。

選択色・リンク色が青系の色だからとても見にくい。
これを改善する為に、DataGridViewのCellFormattingイベントで、リンク色を選択状態に合わせて設定してやれば、多少見やすくなる。
Private Sub dgvLinkColor_CellFormatting( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
Handles dgvLinkColor.CellFormatting
If e.Value Is Nothing Then Exit Sub
''DataGridViewLinkCellの場合だけ処理する
If Me.dgvLinkColor(e.ColumnIndex, e.RowIndex).GetType Is GetType(DataGridViewLinkCell) Then
Dim col As DataGridViewLinkCell
col = TryCast(Me.dgvLinkColor(e.ColumnIndex, e.RowIndex), DataGridViewLinkCell)
If col IsNot Nothing Then
If col.Selected Then
''選択されていたら
col.LinkColor = Color.White
col.VisitedLinkColor = Color.Yellow
Else
''選択されていなかったら標準に戻す(ColLinkは1列目)
col.LinkColor = Me.ColLink.LinkColor
col.VisitedLinkColor = Me.ColLink.VisitedLinkColor
End If
''セルが書式設定された
e.FormattingApplied = True
End If
End If
End Sub

なんとか見やすくなったかな。
|