Re: Winforms Datagrid Cell Text

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Vinny Vinn (VinnyVinn_at_discussions.microsoft.com)
Date: 02/22/05


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
>
>
>



Relevant Pages

  • Re: Subclassing controls
    ... Suppose their is a property called Bold that I can't override. ... own base class version or will it see my new implementation of it? ... At any time, from within the definition of the subclass, you may ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Sub Worksheet _Change()
    ... Your code will bold the selection only when the *entire* range ... When> the override is keyed I want to chnage the color and make the entry> BOLD. ... > Private Sub Worksheet_Change> ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Flex Grid Control
    ... On 28/05/2011 22:32, ralph wrote: ... The grid ... I want to bold the contents of all columns in row 0. ... Chris ...
    (microsoft.public.vb.general.discussion)
  • Re: Need help in comparing the string words in two arrays.
    ... learner9 wrote: ... variable or text in bold using System.out.println.? ... but you really don't want to be messing around with that ...
    (comp.lang.java.programmer)
  • Re: Default Values in Properties Window
    ... > ShouldSearlizeBackColor, it still shows up as bold unless I actually ... > Don't really want to override properties JUST to get default values ...
    (microsoft.public.dotnet.framework.windowsforms.designtime)