• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 616
  • Last Modified:

I have error when I press DataGridView's header

I have error when I press DataGridView's header to order rows

I use this Sub for Icons and  rows's color

===============================

   Private Sub SetGenderImages()
        Dim genderImageCell As DataGridViewImageCell
        Dim I As Double
        Dim Exemption_Color As Boolean


        For Each row As DataGridViewRow In Me.DataGridView1.Rows

            genderImageCell = DirectCast(row.Cells("State"), DataGridViewImageCell)
            If Exemption_Color = True Then I = I + 1

            Select Case row.Cells(5).Value
                Case "False"
                    Exemption_Color = True
                    'genderImageCell.ToolTipText = "Male"
                    Me.DataGridView1.Rows(Me.DataGridView1.CurrentRow.Index() + I).DefaultCellStyle.BackColor = Color.LightYellow
                    genderImageCell.Value = My.Resources.email2

                Case "True"
                    Exemption_Color = True
                    'genderImageCell.ToolTipText = "Female"
                    genderImageCell.Value = My.Resources.email_open1
                    Me.DataGridView1.Rows(Me.DataGridView1.CurrentRow.Index() + I).DefaultCellStyle.BackColor = Color.White


            End Select

        Next row
        I = 0
        Exemption_Color = False
    End Sub
========================================


Look at the Pic before I press DataGridView's header and after that




SystemSys.jpg
SystemSys2.jpg
0
SystemSys
Asked:
SystemSys
  • 2
1 Solution
 
aherpsCommented:
I believe this link may be of use:

http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22808431.html

It leads to here:

http://www.velocityreviews.com/forums/t19572-vbnetimagelist-loses-images-when-the-image-size-property-is-changed.html

create a resource file, then add your images to that resource file,
then read the images from the resource (which gets embedded in your assembly)
at runtime.
0
 
SystemSysAuthor Commented:
I read the images from the resource
         

genderImageCell.Value = My.Resources.email2

Open in new window

ddd.png
0
 
SystemSysAuthor Commented:

I finded my answer

Private Sub DataGridView1_RowHeaderMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DataGridView1.RowHeaderMouseClick

Call SetGenderImages()

End Sub
 
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now