Click here to Skip to main content
15,924,581 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Stupid question Pin
teuneboon24-Feb-06 2:51
teuneboon24-Feb-06 2:51 
GeneralRe: Stupid question Pin
progload24-Feb-06 5:58
progload24-Feb-06 5:58 
GeneralRe: Stupid question Pin
teuneboon24-Feb-06 6:39
teuneboon24-Feb-06 6:39 
AnswerRe: Stupid question Pin
Allah On Acid23-Feb-06 10:41
Allah On Acid23-Feb-06 10:41 
AnswerRe: Stupid question Pin
Christian Graus23-Feb-06 12:48
protectorChristian Graus23-Feb-06 12:48 
GeneralRe: Stupid question Pin
Colin Angus Mackay23-Feb-06 12:53
Colin Angus Mackay23-Feb-06 12:53 
GeneralRe: Stupid question Pin
Christian Graus23-Feb-06 12:55
protectorChristian Graus23-Feb-06 12:55 
QuestionDataGridView row background color Pin
Brent Lamborn23-Feb-06 6:24
Brent Lamborn23-Feb-06 6:24 
Hello...

Working with VS 2005 Final Release. I hava a DataGridView in which I would like the row to be highlighted a different color if the value in the row's "TAG" column is equal to the the text "NOTE_TEXT". All rows that have "NOTE_TEXT" as the value in the "TAG" column should be highlighted.

I know I can use the RowPrePaint event to do this but I am not sure how to determine which rows contain "NOTE_TEXT" in the "TAG" column within that event.

Here is the code for the event pulled from this page[^] (excellent article Btw... Big Grin | :-D )

 Private Sub dgvOne_RowPrePaint(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewRowPrePaintEventArgs) Handles dgvOne.RowPrePaint<br />
<br />
        ' Do not automatically paint the focus rectangle.<br />
        e.PaintParts = e.PaintParts And Not DataGridViewPaintParts.Focus<br />
<br />
        ' Determine whether the cell should be painted with the <br />
        ' custom selection background.<br />
<br />
        If (e.State And DataGridViewElementStates.Selected) = _<br />
            DataGridViewElementStates.Selected Then<br />
<br />
            ' Calculate the bounds of the row.<br />
            Dim rowBounds As New Rectangle( _<br />
                Me.dgvOne.RowHeadersWidth, e.RowBounds.Top, _<br />
                Me.dgvOne.Columns.GetColumnsWidth( _<br />
                DataGridViewElementStates.Visible) - _<br />
                Me.dgvOne.HorizontalScrollingOffset + 1, _<br />
                e.RowBounds.Height)<br />
<br />
            ' Paint the custom selection background.<br />
            Dim backbrush As New _<br />
                System.Drawing.Drawing2D.LinearGradientBrush(rowBounds, _<br />
                Me.dgvOne.DefaultCellStyle.SelectionBackColor, _<br />
                e.InheritedRowStyle.ForeColor, _<br />
                System.Drawing.Drawing2D.LinearGradientMode.Horizontal)<br />
            Try<br />
                e.Graphics.FillRectangle(backbrush, rowBounds)<br />
            Finally<br />
                backbrush.Dispose()<br />
            End Try<br />
        End If<br />
    End Sub


I need to change this if statement:

If (e.State And DataGridViewElementStates.Selected) = _<br />
    DataGridViewElementStates.Selected Then


so that it decides if the row being painted contains "NOTE_TEXT" in its "TAG" column.

Any ideas? This should be a fun one...

Many thanks!

"Half this game is ninety percent mental."
- Yogi Berra

If you can read thank a teacher, if you can read in English, thank a Marine.
AnswerRe: DataGridView row background color Pin
abhinish24-Feb-06 1:30
abhinish24-Feb-06 1:30 
GeneralRe: DataGridView row background color Pin
Brent Lamborn24-Feb-06 3:38
Brent Lamborn24-Feb-06 3:38 
Question[Message Deleted] Pin
ironstrike123-Feb-06 5:01
ironstrike123-Feb-06 5:01 
AnswerRe: need help, will pay Pin
J4amieC23-Feb-06 5:06
J4amieC23-Feb-06 5:06 
General[Message Deleted] Pin
ironstrike123-Feb-06 5:42
ironstrike123-Feb-06 5:42 
GeneralRe: need help, will pay Pin
Guffa23-Feb-06 8:08
Guffa23-Feb-06 8:08 
GeneralRe: need help, will pay Pin
ironstrike123-Feb-06 8:35
ironstrike123-Feb-06 8:35 
GeneralRe: need help, will pay Pin
Guffa23-Feb-06 9:50
Guffa23-Feb-06 9:50 
GeneralRe: need help, will pay Pin
Andy *M*23-Feb-06 12:45
Andy *M*23-Feb-06 12:45 
GeneralRe: need help, will pay Pin
Andy *M*24-Feb-06 2:06
Andy *M*24-Feb-06 2:06 
GeneralRe: need help, will pay Pin
ironstrike124-Feb-06 2:30
ironstrike124-Feb-06 2:30 
AnswerRe: need help, will pay Pin
progload23-Feb-06 8:42
progload23-Feb-06 8:42 
GeneralRe: need help, will pay Pin
ironstrike123-Feb-06 8:53
ironstrike123-Feb-06 8:53 
GeneralRe: need help, will pay Pin
progload23-Feb-06 9:04
progload23-Feb-06 9:04 
GeneralRe: need help, will pay Pin
ironstrike123-Feb-06 9:06
ironstrike123-Feb-06 9:06 
GeneralRe: need help, will pay Pin
J4amieC23-Feb-06 9:21
J4amieC23-Feb-06 9:21 
General[Message Deleted] Pin
ironstrike123-Feb-06 9:25
ironstrike123-Feb-06 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.