How to highlight MSFlexGrid row?-VBForums
Results 1 to 6 of 6

Thread: How to highlight MSFlexGrid row?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    49

    How to highlight MSFlexGrid row?

    Hi,
    Im working with a form where all the item details are placed in MSFlexGrid and on clicking the Save button the code verifies the MSFlexgrid's item number column to avoid duplicate entries.

    Now, what I want is to highlight with red all the duplicate rows at once when Save is clicked, i.e, it should show multiple entries in red.

    My code works as:
    1. when Save is clicked it highlights only one row at a time
    2. it gets highlighted only when user clicks the row
    3. every row gets highlighted in red on clicking the msflexgrid's row making it indistinguishable with the duplicate ones unless Save is clicked again.

    Here is my code, could anyone help me with this?

    Code:
     
     Private Sub cmdSave_Click()    
         'open Item table
         Set myrs2 = New ADODB.Recordset
         myrs2.Open "Item", mycon, adOpenKeyset, adLockPessimistic, adCmdTable
         'verify item numer for duplicate entry
         Dim x As Integer
         For x = 1 To MSFlexGrid1.Rows - 1
           If MSFlexGrid1.TextMatrix(x, 0) = myrs2.Fields("ItemNumber") Then
            With MSFlexGrid1
            MsgBox "Duplicate Item Number(s) found! Please edit or remove the corresponding Item details.", vbOKOnly + vbCritical, "Duplicate Entry"
             .Row = x
             .Col = 0
             .BackColorSel = vbRed
            End With
           End If
         Next
    end Sub

  2. #2

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    49

    Re: How to highlight MSFlexGrid row?

    Im sorry, but could you brief it out. The link has puzzled me further.

  4. #4
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,827

    Re: How to highlight MSFlexGrid row?

    Did you notice post #4 in the thread linked by RB?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  5. #5

    Thread Starter
    Member
    Join Date
    Jul 2006
    Posts
    49

    Re: How to highlight MSFlexGrid row?

    ok i finally tried and got it as desired but only one point is left. It does not highlight only the duplicate fields instead it highlights all the rows of MSFlexGrid.

    Could anyone correct me as to what is going wrong? Here is the modified code:

    Code:
    'open Item table
         Set myrs2 = New ADODB.Recordset
         myrs2.Open "Item", mycon, adOpenKeyset, adLockPessimistic, adCmdTable
         'verify item numer for duplicate entry
         Dim z As Integer
         For z = 1 To MSFlexGrid1.Rows - 1
         If MSFlexGrid1.TextMatrix(z, 0) = myrs2.Fields("ItemNumber") Then
          With MSFlexGrid1
          MsgBox "Duplicate Item Number(s) found! Please edit or remove the corresponding Item details.", vbOKOnly + vbCritical, "Duplicate Entry"
          Dim y%, x%
          For x = 1 To .Rows - 1
           For y = 1 To .Cols - 1
             .Row = x
             .Col = y
             .CellBackColor = vbRed
           Next y
          Next x
          End With
          Exit Sub
         End If
         'Exit Sub
         Next z

  6. #6
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Candon City, Ilocos Sur, Phils.
    Posts
    10,827

    Re: How to highlight MSFlexGrid row?

    Of course you need to put logic to determine the duplicate fields.
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.