Ciao a tutti,
ho l'esigenza di inserire nelle celle del datagridview oltre che al valore numerico una freccia su/giu verde/rossa a secondo del valore della cella.
Cercato in rete, trovato queste due sub funziona perfettamente.
Non ho capito il funzionamento, ho solo capito come si fa a cambiare il simbolo e a secondo del valore.
Vorrei capire meglio il funzionamento delle Sub anche perche' non riesco a cambiare il font(Dimensioni e grassetto della cella in cui vado ad abbinare la freccia
grazie a tutti.


Private Sub DataGridView_CellPainting(ByVal pcolumn As Integer, ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellPaintingEvent Args)

'------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------
'------- QUESTA SABRUTIN SERVE PER METTERE LE FRECCE E LA STRINGA IN UNA UNICA CELLA DEL DATAGRIDVIEW ------
'------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------

Dim zsignimage As Image = Nothing
Dim format As New StringFormat()
If e.ColumnIndex = pcolumn AndAlso e.RowIndex > -1 Then


Select Case Replace(e.Value, "%", "")

Case 0
zsignimage = ImageList1.Images.Item(4)
Case Is = "0,00"
zsignimage = ImageList1.Images.Item(4)
Case Is = "NaN"
zsignimage = ImageList1.Images.Item(4)
Case Is > 0
zsignimage = ImageList1.Images.Item(1)
Case Is < 0
zsignimage = ImageList1.Images.Item(2)
End Select

'e.CellStyle.Font = New Font(“Tahoma”, 15, FontStyle.Bold)
e.PaintBackground(e.ClipBounds, True) 'transparant in cursor
'draw icon image
format.LineAlignment = StringAlignment.Center
format.Alignment = StringAlignment.Near
Dim x As Integer = (e.CellBounds.Width / 4)
Dim iconRect = New Rectangle(e.CellBounds.Left + 7, e.CellBounds.Top + 1, x - 7, e.CellBounds.Height - 4)
e.Graphics.DrawImage(zsignimage, iconRect)
'draw text
format.LineAlignment = StringAlignment.Center
format.Alignment = StringAlignment.Far
Dim textRect = New Rectangle(e.CellBounds.Left, e.CellBounds.Top, e.CellBounds.Width, e.CellBounds.Height)
e.Graphics.DrawString(e.Value, Font, Brushes.Black, textRect, format)
e.CellStyle.SelectionBackColor = Color.Transparent
e.Handled = True
End If
End Sub


Private Sub DataGridView1_CellPainting(sender As Object, e As DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
' '----------------------------------------------------------------------------------------------------------------------------------
' '----------------------------------------------------------------------------------------------------------------------------------
' '------- QUESTA SABRUTIN SERVE PER METTERE LA FRECCIA Nella Colonna scelta E LA STRINGA IN UNA UNICA CELLA DEL DATAGRIDVIEW ------
' '----------------------------------------------------------------------------------------------------------------------------------
' '----------------------------------------------------------------------------------------------------------------------------------
DataGridView_CellPainting(3, sender, e) '3 is column index of "Change"
End Sub