Foros del Web » Programación para mayores de 30 ;) » .NET »

datagrid con imagen VS 2003 .NET

Estas en el tema de datagrid con imagen VS 2003 .NET en el foro de .NET en Foros del Web. Hola he buscado bastante y aun no encuentro la manera de poner una imagen en un datagrd, ocupo VS 2003 .NET. alguna idea... o no ...
  #1 (permalink)  
Antiguo 04/09/2008, 10:37
 
Fecha de Ingreso: marzo-2005
Mensajes: 123
Antigüedad: 19 años, 1 mes
Puntos: 1
datagrid con imagen VS 2003 .NET

Hola he buscado bastante y aun no encuentro la manera de poner una imagen en un datagrd, ocupo VS 2003 .NET.

alguna idea... o no se puede :(

Gracias
  #2 (permalink)  
Antiguo 04/09/2008, 10:44
 
Fecha de Ingreso: agosto-2008
Mensajes: 48
Antigüedad: 15 años, 7 meses
Puntos: 2
Respuesta: datagrid con imagen VS 2003 .NET

usa un item template de tipo imagen
  #3 (permalink)  
Antiguo 04/09/2008, 11:20
Avatar de Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 16 años, 7 meses
Puntos: 87
Respuesta: datagrid con imagen VS 2003 .NET

si es windows como me lo imagino

lee este articulo http://www.vbdotnetforums.com/winfor...ows-forms.html

si fuera web el itemtemplate vale.
__________________
Curso WF4
http://cursos.gurudotnet.com/ DF
Aprende HTML5
  #4 (permalink)  
Antiguo 04/09/2008, 13:43
 
Fecha de Ingreso: marzo-2005
Mensajes: 123
Antigüedad: 19 años, 1 mes
Puntos: 1
Respuesta: datagrid con imagen VS 2003 .NET

No me muestra nada :(

Esto puse en el formulario

Dim ts As New DataGridTableStyle
ts.MappingName = "ParentTable"

Dim ImageCol As New ImageColumnStyle '<-- Name of class
With ImageCol
.ImageList = ImageList1 '<-- My imagelist object
.BackColor = Brushes.White
.ForeColor = Brushes.Black
.RightToLeft = True
.MappingName = "Icon"
.HeaderText = ""
.Width = ImageList1.ImageSize.Width + 4
.Alignment = HorizontalAlignment.Center
.ReadOnly = True
End With
ts.GridColumnStyles.Add(ImageCol)
DataGrid1.DataSource = ds.Tables(0)
DataGrid1.TableStyles.Add(ts)
DataGrid1.Refresh()

y esta es la clase

Imports System.Drawing
Imports System
Imports System.Windows.Forms
Public Class ImageColumnStyle
Inherits DataGridColumnStyle
Public ImageList As ImageList
Private Image As Image
Private bBackcolor As Brush
Private bForeColor As Brush
Private bRightToLeft As Boolean
Protected Overrides Sub Abort(ByVal rowNum As Integer)
Invalidate()
End Sub
Protected Overrides Function Commit(ByVal dataSource As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer) As Boolean
Return True
End Function
Protected Overloads Overrides Sub Edit(ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal bounds As System.Drawing.Rectangle, ByVal [readOnly] As Boolean, ByVal instantText As String, ByVal cellIsVisible As Boolean)
End Sub
Protected Overrides Function GetMinimumHeight() As Integer
Return ImageList.ImageSize.Height
End Function
Protected Overrides Function GetPreferredHeight(ByVal g As System.Drawing.Graphics, ByVal value As Object) As Integer
Return ImageList.ImageSize.Height
End Function
Protected Overrides Function GetPreferredSize(ByVal g As System.Drawing.Graphics, ByVal value As Object) As System.Drawing.Size
Return ImageList.ImageSize
End Function
Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer)
Paint(g, bounds, source, rowNum, BackColor, ForeColor, RightToLeft)
End Sub
Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal alignToRight As Boolean)

End Sub
Protected Overloads Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal bounds As System.Drawing.Rectangle, ByVal source As System.Windows.Forms.CurrencyManager, ByVal rowNum As Integer, ByVal BackBrush As Brush, ByVal ForeBrush As Brush, ByVal alignToRight As Boolean)
Dim index = GetColumnValueAtRow(source, rowNum)
If Not IsDBNull(index) Then
InitImage(index)
Dim rect As Rectangle = New Rectangle(bounds.Location, ImageList.ImageSize)
g.FillRectangle(BackBrush, bounds)
g.DrawImage(Image, rect)
End If
End Sub
Private Sub InitImage(ByVal index As Integer)
If Not IsDBNull(ImageList) And ImageList.Images.Count >= index + 1 Then
Image = ImageList.Images(index)
End If
End Sub
Property BackColor() As Brush
Get
Return BackColor
End Get
Set(ByVal Value As Brush)
bBackcolor = Value
End Set
End Property
Property ForeColor() As Brush
Get
Return ForeColor
End Get
Set(ByVal Value As Brush)
bForeColor = Value
End Set
End Property
Property RightToLeft() As Boolean
Get
Return RightToLeft
End Get
Set(ByVal Value As Boolean)
bRightToLeft = Value
End Set
End Property
End Class


Ayuda por favor.... gracias
  #5 (permalink)  
Antiguo 08/09/2008, 07:27
 
Fecha de Ingreso: marzo-2005
Mensajes: 123
Antigüedad: 19 años, 1 mes
Puntos: 1
Respuesta: datagrid con imagen VS 2003 .NET

Aun no me resulta :(
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:17.