Re: Winforms Datagrid Cell Text
From: Vinny Vinn (VinnyVinn_at_discussions.microsoft.com)
Date: 02/22/05
- Next message: Terry A.: "Re: Visual C#.NET IDE-Component window"
- Previous message: Jay B. Harlow [MVP - Outlook]: "Re: cannot convert type system.web.ui.webcontrols.unit to double"
- In reply to: Chris, Master of All Things Insignificant: "Re: Winforms Datagrid Cell Text"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 12:05:02 -0800
Thanks Chris,i was hoping there was a 'prettier' way then override the Paint
event
"Chris, Master of All Things Insignifican" wrote:
> The way I did that is to override the Paint event of the DataGridColumnStyle
> class. Couple things to note. There are several overloaded subs to deal
> with, most just call a simpler version in the end. The example I have below
> doesn't bold the font, it just changes the back/fore color but the brush is
> what you need do the bold to I believe. Hope this helps.
>
> Chris
>
>
> Protected Overloads Overrides Sub Paint(ByVal g As Graphics, _
> ByVal Bounds As Rectangle, _
> ByVal Source As CurrencyManager, _
> ByVal RowNum As Integer, _
> ByVal AlignToRight As Boolean)
>
> Dim Text As String = GetText(GetColumnValueAtRow(Source, RowNum))
> Dim DR As DataRow
> DR = DirectCast(Source.Current, DataRowView).DataView.Item(RowNum).Row
> If SomthingHappenedThen
> Dim BackBrush As Brush = New SolidBrush(Me.DataGridTableStyle.BackColor)
> Dim ForeBrush As Brush = New SolidBrush(System.Drawing.Color.Salmon)
> PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
> ElseIf SomthingElseHappened Then
> Dim BackBrush As Brush = New SolidBrush(Me.DataGridTableStyle.BackColor)
> Dim ForeBrush As Brush = New SolidBrush(System.Drawing.Color.RosyBrown)
> PaintText(g, Bounds, Text, BackBrush, ForeBrush, AlignToRight)
> Else
> PaintText(g, Bounds, Text, AlignToRight)
> End If
>
> End Sub
> "Vinny Vinn" <VinnyVinn@discussions.microsoft.com> wrote in message
> news:341B41D0-CBC8-419C-89CE-EC594FA38F74@microsoft.com...
> > Any ideas on how i can bold the text within a specific cell of a winforms
> > datagrid?i have used DataGridColumnStyle for an entire column,however
> > currently i need just the text of a specific cell to be bold?
> >
> > Thanks
>
>
>
- Next message: Terry A.: "Re: Visual C#.NET IDE-Component window"
- Previous message: Jay B. Harlow [MVP - Outlook]: "Re: cannot convert type system.web.ui.webcontrols.unit to double"
- In reply to: Chris, Master of All Things Insignificant: "Re: Winforms Datagrid Cell Text"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|