Visual Basic.NET - Imagen como enlace en una celda de un datagridview

 
Vista:

Imagen como enlace en una celda de un datagridview

Publicado por Felix (2 intervenciones) el 12/02/2009 17:33:02
hola a todos. Por favor si pudieran ayudarme. Quiero colocar una celda que diga quitar por fila de un datagridview con la finalidad de quitar esa fila cuando clickeo sobre la celda con imagen de esa misma fila, algo asi como tienen algunas paginas donde agregas y quitas filas pero los iconos estan en la misma fila.

Mi problema es que no se como darle apariencia de link o hacer que el cursor cambie su forma a la manito cuando este sobre la celda con imagen.

Si pudieran ayudame les estaria muy agradecido.

para celda con imagen uso el tipo de celda imagecolumn.

Gracias de antemano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE: SOLUCION AL PROBLEMA

Publicado por Felix (2 intervenciones) el 12/02/2009 23:14:12
Ya lo solucione. Aqui les mando el codigo por si les sirva.

Public Class DataGridViewRolloverCell
Inherits DataGridViewImageCell

Protected Overrides Sub Paint( _
ByVal graphics As Graphics, _
ByVal clipBounds As Rectangle, _
ByVal cellBounds As Rectangle, _
ByVal rowIndex As Integer, _
ByVal elementState As DataGridViewElementStates, _
ByVal value As Object, _
ByVal formattedValue As Object, _
ByVal errorText As String, _
ByVal cellStyle As DataGridViewCellStyle, _
ByVal advancedBorderStyle As DataGridViewAdvancedBorderStyle, _
ByVal paintParts As DataGridViewPaintParts)

' Call the base class method to paint the default cell appearance.
MyBase.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, _
value, formattedValue, errorText, cellStyle, _
advancedBorderStyle, paintParts)

' Retrieve the client location of the mouse pointer.
Dim cursorPosition As Point = _
Me.DataGridView.PointToClient(Cursor.Position)

' If the mouse pointer is over the current cell, draw a custom border.
If cellBounds.Contains(cursorPosition) Then
Dim newRect As New Rectangle(cellBounds.X + 1, _
cellBounds.Y + 1, cellBounds.Width - 4, _
cellBounds.Height - 4)
graphics.DrawRectangle(Pens.Red, newRect)
End If

End Sub

'Force the cell to repaint itself when the mouse pointer enters it.
Protected Overrides Sub OnMouseEnter(ByVal rowIndex As Integer)
Me.DataGridView.InvalidateCell(Me)
Me.DataGridView.Cursor = Cursors.Hand
End Sub

' Force the cell to repaint itself when the mouse pointer leaves it.
Protected Overrides Sub OnMouseLeave(ByVal rowIndex As Integer)
Me.DataGridView.InvalidateCell(Me)
Me.DataGridView.Cursor = Cursors.Arrow
End Sub

End Class

Public Class DataGridViewRolloverCellColumn
Inherits DataGridViewImageColumn

Public Sub New()
Me.CellTemplate = New DataGridViewRolloverCell()
End Sub

End Class

'LUEGO A LA COLUMNA DEL DATAGRIDVIEW QUE QUIEREN QUE TENGA ESTA APARIENCIA LA CREAN CON EL SGTE CODIGO:

With DATAGRIDVIEW
.Columns.Clear()
Dim Column01 As New DataGridViewRolloverCellColumn
With Column01
.Name = "C_image"
.DataPropertyName = "C_image"
.HeaderText = "Quitar"
.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Image = (iconImg.Images(1))

End With
.Columns.Add(Column01)
End With
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar