Retroceder   Foros del Web > Programación para sitios web > .NET > win forms

Respuesta
 
Herramientas Desplegado
Antiguo 17-ene-2008, 16:12   #1 (permalink)
juanutcm está en el buen camino
 
Avatar de juanutcm
 
Fecha de Ingreso: marzo-2005
Mensajes: 194
Enviar un mensaje por MSN a juanutcm
Pregunta DateTimePicker en DataGridView

Hola a todos bueno encontre este codigo en otro foro


Cita:
Para conseguir mostrar una columna de un DataGridView cuyas celdas contengan
a su vez otro control, por ejemplo DateTimePicker, debes realizar varios
pasos que permitan a un objeto DataGridViewColumn -la clase base de las
columnas mostradas por un DataGridView- visualizar el control en cada una de
sus celdas.

En primer lugar debes crear una clase que herede del control que quieres
incrustar en las celdas, en este caso DateTimePicker, implementando también
la interfaz IDataGridViewEditingControl, que nos permitirá realizar la
edición del valor de una celda utilizando el mencionado control. Debemos
escribir el código para aquellas propiedades y métodos encargados de las
operaciones de edición de forma similar a como puedes ver en el siguiente
bloque de código:

'////////////////////////////////
Public Class EditorValorCelda
Inherits DateTimePicker
Implements IDataGridViewEditingControl

' variables de uso interno
Private nNumeroFila As Integer
Private oDGV As DataGridView
Private bValorCambiado As Boolean = False

' propiedades
Public Property EditingControlDataGridView() As
System.Windows.Forms.DataGridView Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlDataGridView
Get
Return oDGV
End Get
Set(ByVal value As System.Windows.Forms.DataGridView)
oDGV = value
End Set
End Property

Public Property EditingControlFormattedValue() As Object Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlFormattedVal­ue
Get
Return Me.Value
End Get
Set(ByVal value As Object)
Me.Value = value
End Set
End Property

Public Property EditingControlRowIndex() As Integer Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlRowIndex
Get
Return nNumeroFila
End Get
Set(ByVal value As Integer)
nNumeroFila = value
End Set
End Property

Public Property EditingControlValueChanged() As Boolean Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlValueChanged
Get
Return bValorCambiado
End Get
Set(ByVal value As Boolean)
bValorCambiado = value
End Set
End Property

Public ReadOnly Property EditingPanelCursor() As
System.Windows.Forms.Cursor Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingPanelCursor
Get
Return MyBase.Cursor
End Get
End Property

Public ReadOnly Property RepositionEditingControlOnValueChange() As
Boolean Implements
System.Windows.Forms.IDataGridViewEditingControl.R epositionEditingControlOn­ValueChange
Get
Return False
End Get
End Property

' métodos
Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As
System.Windows.Forms.DataGridViewCellStyle) Implements
System.Windows.Forms.IDataGridViewEditingControl.A pplyCellStyleToEditingCon­trol
Me.Font = dataGridViewCellStyle.Font
Me.ForeColor = dataGridViewCellStyle.ForeColor
Me.BackColor = dataGridViewCellStyle.BackColor
End Sub

Public Function EditingControlWantsInputKey(ByVal keyData As
System.Windows.Forms.Keys, ByVal dataGridViewWantsInputKey As Boolean) As
Boolean Implements
System.Windows.Forms.IDataGridViewEditingControl.E ditingControlWantsInputKe­y
Select Case keyData And Keys.KeyCode
Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, _
Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp

Return True
Case Else
Return False
End Select
End Function

Public Function GetEditingControlFormattedValue(ByVal context As
System.Windows.Forms.DataGridViewDataErrorContexts ) As Object Implements
System.Windows.Forms.IDataGridViewEditingControl.G etEditingControlFormatted­Value
Return Me.Value.ToString("dd-MM-yyyy")
End Function

Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
bValorCambiado = True
Me.EditingControlDataGridView.NotifyCurrentCellDir ty(True)
MyBase.OnTextChanged(e)

End Sub

Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean)
Implements
System.Windows.Forms.IDataGridViewEditingControl.P repareEditingControlForEd­it
' no es necesario codificar este método
End Sub
End Class
'////////////////////////////////

A continuación creamos una clase que herede de algunas de las clases que el
control DataGridView utiliza para la manipulación de los valores de sus
celdas. La clase base abstracta de este tipo es DataGridViewCell, y heredando
de esta tenemos DataGridViewTextBoxCell que representa una celda de valores
en formato texto. Podemos crear una clase que herede de esta última,
reemplazando aquellos miembros de la clase que necesitemos para mostrar la
información en la celda, como puedes ver en el siguiente bloque de código:

'////////////////////////////////
Public Class CeldaPersonalizada
Inherits DataGridViewTextBoxCell

' propiedades
Public Overrides ReadOnly Property EditType() As System.Type
Get
Return GetType(EditorValorCelda)
End Get
End Property

Public Overrides ReadOnly Property ValueType() As System.Type
Get
Return GetType(Date)
End Get
End Property

Public Overrides ReadOnly Property DefaultNewRowValue() As Object
Get
Return Date.Now
End Get
End Property

' métodos
Public Sub New()
'....
End Sub

Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _
ByVal initialFormattedValue As Object, _
ByVal dataGridViewCellStyle As DataGridViewCellStyle)

MyBase.InitializeEditingControl(rowIndex, initialFormattedValue,
dataGridViewCellStyle)

Dim ctlEditorValorCelda As EditorValorCelda =
CType(DataGridView.EditingControl, EditorValorCelda)
Dim colColumnaPersonalizada As ColumnaPersonalizada =
CType(Me.OwningColumn, ColumnaPersonalizada)

ctlEditorValorCelda.Text = initialFormattedValue
End Sub
End Class
'////////////////////////////////

Finalmente crearemos una tercera clase que herede de la clase base
DataGridViewColumn, y que será utilizada por el control para construir la
columna a partir de las celdas personalizadas creadas en las anteriores
clases que hemos escrito.

'////////////////////////////////
Public Class ColumnaPersonalizada
Inherits DataGridViewColumn

' propiedades
Public Overrides Property CellTemplate() As
System.Windows.Forms.DataGridViewCell
Get
Return MyBase.CellTemplate
End Get
Set(ByVal value As System.Windows.Forms.DataGridViewCell)
MyBase.CellTemplate = value
End Set
End Property

'métodos
Public Sub New()
MyBase.New(New CeldaPersonalizada())
End Sub
End Class
'////////////////////////////////

Ya tenemos creada nuestra columna personalizada para el grid, por lo que el
único paso que nos queda es utilizarlo en un formulario al que hayamos
agregado un DataGridView.

'////////////////////////////////
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim oConexion As SqlConnection = New SqlConnection()
oConexion.ConnectionString = "Data Source=localhost;" & _
"Initial Catalog=AdventureWorksDW;" & _
"User ID=sa;Password=abc"

Dim oComando As SqlCommand = New SqlCommand("SELECT
CustomerKey,FirstName,LastName,DateFirstPurchase " & _
"FROM DimCustomer", _
oConexion)
Dim oDataAdapter As SqlDataAdapter = New SqlDataAdapter(oComando)
Dim oDataSet As DataSet = New DataSet()
oDataAdapter.Fill(oDataSet, "DimCustomer")

Me.DataGridView1.DataSource = oDataSet
Me.DataGridView1.DataMember = "DimCustomer"

' quitar la columna original que sustituiremos
' por nuestra columna personalizada
Me.DataGridView1.Columns.Remove("DateFirstPurchase ")

' crear un objeto de nuestra columna personalizada y añadirlo
' a la colección de columnas del DataGridView
Dim oMCCol As ColumnaPersonalizada = New ColumnaPersonalizada()
oMCCol.Width = 200
oMCCol.HeaderText = "Fecha primera compra"
oMCCol.DataPropertyName = "DateFirstPurchase"
Me.DataGridView1.Columns.Add(oMCCol)
End Sub
'////////////////////////////////

Y básicamente esto sería todo, en función del tipo de control que quieras
utilizar para realizar la edición del valor es posible que tengas que hacer
algunos ajustes en el código.

Espero que te sea de utilidad.
--
paso el enlace para quien quiera checarlo:

http://groups.google.es/group/micros...31e102c0d9d65f

bueno mi punto es que este codigo inserta una columna con celdas con formato de datetimepicker... y lo que requiero yo es que cuando le cargue los datos al datagridview :

datagridview.datasource=datatable

se modifique el formato de las celdas de la columna fecha y si tiene datos cargados ese registro muestre la fecha... estuve leyendo el codigo pero no le entiendo mucho ojala que alguien me pueda ayudar ...

desde ahora muchas gracias por sus aportes... y cualquier cosa aqui ando por si no me explique con claridad... y mas detalles
__________________
L.C.I. Juan Jesús

--- El sabio no dice nunca todo lo que piensa, pero siempre piensa todo lo que dice. ---
juanutcm está desconectado   Responder Citando
Antiguo 20-feb-2008, 10:51   #2 (permalink)
juanutcm está en el buen camino
 
Avatar de juanutcm
 
Fecha de Ingreso: marzo-2005
Mensajes: 194
Enviar un mensaje por MSN a juanutcm
Solucion DateTimePicker en DataGridView Parte I

Muy bien despues de tanta investigacion y probar por fin consegui lo buscado en seguida pongo el codigo por si a alguien le sirve de algo....

ESTE SEGMENTO DE CODIGO SE INSERTA EN EL EVENTO LOAD DEL FORMULARIO O EN EL EVENTO EN EL QUE SE MANDE LLAMAR A LA INICIALIZACION DEL DATAGRIDVIEW CORRESPONDIENTE

Código:
'SECCION PARA LA AGREGAR COLUMNA DE FECHA
      Dim col As New CalendarColumn() 'Crear columna de tipo CalendarColumn
      Me.DataGridView1.Columns.RemoveAt(IndiceNumeroColumna) 'Eliminar la columna especificada
      Me. DataGridView1.Columns.Insert(IndiceNumeroColumna, col) 'Insertar columna de tipo CalendarColumn
      Me.DataGridView1.Columns(IndiceNumeroColumna).DataPropertyName = "FechaInicio" 'Asignar el nombre del campo de la base de datos a la columna especificada
      Me. DataGridView1.Columns(IndiceNumeroColumna).HeaderText = "FECHA DE INICIO" 'Asignar el nombre a mostrar en la columna
'SECCION PARA LA AGREGAR COLUMNA DE FECHA
__________________
L.C.I. Juan Jesús

--- El sabio no dice nunca todo lo que piensa, pero siempre piensa todo lo que dice. ---
juanutcm está desconectado   Responder Citando
Antiguo 20-feb-2008, 10:55   #3 (permalink)
juanutcm está en el buen camino
 
Avatar de juanutcm
 
Fecha de Ingreso: marzo-2005
Mensajes: 194
Enviar un mensaje por MSN a juanutcm
Solucion DateTimePicker en DataGridView Parte II

ESTE SEGMENTO DE CODIGO SE INSERTA EN LA CLASE PRINCIPAL DEL FORMULARIO EJ.:
Public Class Form1
SEGMENTO DE CODIGO QUE APARECE ABAJO
End Class

Código:
Public Class CalendarColumn
Inherits DataGridViewColumn
 
Public Sub New()
MyBase.New(New CalendarCell())
End Sub
 
Public Overrides Property CellTemplate() As DataGridViewCell
Get
Return MyBase.CellTemplate
End Get
Set(ByVal value As DataGridViewCell)
 
' Ensure that the cell used for the template is a CalendarCell.
If (value IsNot Nothing) AndAlso _
Not value.GetType().IsAssignableFrom(GetType(CalendarCell)) _
Then
Throw New InvalidCastException("Must be a CalendarCell")
End If
MyBase.CellTemplate = value
 
End Set
End Property
 
End Class
 
Public Class CalendarCell
Inherits DataGridViewTextBoxCell
 
Public Sub New()
' Use the short date format.
Me.Style.Format = "d"
End Sub
 
Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, _
ByVal initialFormattedValue As Object, _
ByVal dataGridViewCellStyle As DataGridViewCellStyle)
 
' Set the value of the editing control to the current cell value.
MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, _
dataGridViewCellStyle)
 
Dim ctl As CalendarEditingControl = _
CType(DataGridView.EditingControl, CalendarEditingControl)
If Me.Value.ToString <> Nothing Then
 
ctl.Value = CType(Me.Value, DateTime)
Else
ctl.Value = Today
End If
End Sub
 
Public Overrides ReadOnly Property EditType() As Type
Get
' Return the type of the editing contol that CalendarCell uses.
Return GetType(CalendarEditingControl)
End Get
End Property
 
Public Overrides ReadOnly Property ValueType() As Type
Get
' Return the type of the value that CalendarCell contains.
Return GetType(DateTime)
End Get
End Property
__________________
L.C.I. Juan Jesús

--- El sabio no dice nunca todo lo que piensa, pero siempre piensa todo lo que dice. ---
juanutcm está desconectado   Responder Citando
Antiguo 20-feb-2008, 10:56   #4 (permalink)
juanutcm está en el buen camino
 
Avatar de juanutcm
 
Fecha de Ingreso: marzo-2005
Mensajes: 194
Enviar un mensaje por MSN a juanutcm
Solucion DateTimePicker en DataGridView Parte III

Código:
Public Overrides ReadOnly Property DefaultNewRowValue() As Object
          Get
              ' Use the current date and time as the default value.
              Return DateTime.Now
          End Get
      End Property
 
  End Class
 
  Class CalendarEditingControl
      Inherits DateTimePicker
      Implements IDataGridViewEditingControl
 
      Private dataGridViewControl As DataGridView
      Private valueIsChanged As Boolean = False
      Private rowIndexNum As Integer
 
      Public Sub New()
          Me.Format = DateTimePickerFormat.Short
      End Sub
 
      Public Property EditingControlFormattedValue() As Object _
          Implements IDataGridViewEditingControl.EditingControlFormattedValue
 
          Get
              Return Me.Value.ToShortDateString()
          End Get
 
          Set(ByVal value As Object)
              If TypeOf value Is String Then
                  Me.Value = DateTime.Parse(CStr(value))
              End If
          End Set
 
      End Property
 
      Public Function GetEditingControlFormattedValue(ByVal context _
          As DataGridViewDataErrorContexts) As Object _
          Implements IDataGridViewEditingControl.GetEditingControlFormattedValue
 
          Return Me.Value.ToShortDateString()
 
      End Function
 
      Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As _
          DataGridViewCellStyle) _
          Implements IDataGridViewEditingControl.ApplyCellStyleToEditingControl
 
          Me.Font = dataGridViewCellStyle.Font
          Me.CalendarForeColor = dataGridViewCellStyle.ForeColor
          Me.CalendarMonthBackground = dataGridViewCellStyle.BackColor
 
      End Sub
 
      Public Property EditingControlRowIndex() As Integer _
          Implements IDataGridViewEditingControl.EditingControlRowIndex
 
          Get
              Return rowIndexNum
          End Get
          Set(ByVal value As Integer)
              rowIndexNum = value
          End Set
 
      End Property
 
      Public Function EditingControlWantsInputKey(ByVal key As Keys, _
          ByVal dataGridViewWantsInputKey As Boolean) As Boolean _
          Implements IDataGridViewEditingControl.EditingControlWantsInputKey
 
          ' Let the DateTimePicker handle the keys listed.
          Select Case key And Keys.KeyCode
              Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, _
                  Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp
 
                  Return True
 
              Case Else
                  Return False
          End Select
 
      End Function
__________________
L.C.I. Juan Jesús

--- El sabio no dice nunca todo lo que piensa, pero siempre piensa todo lo que dice. ---
juanutcm está desconectado   Responder Citando
Antiguo 20-feb-2008, 10:57   #5 (permalink)
juanutcm está en el buen camino
 
Avatar de juanutcm
 
Fecha de Ingreso: marzo-2005
Mensajes: 194
Enviar un mensaje por MSN a juanutcm
Solucion DateTimePicker en DataGridView Parte IV

Código:
Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) _
         Implements IDataGridViewEditingControl.PrepareEditingControlForEdit
 
         ' No preparation needs to be done.
 
     End Sub
 
     Public ReadOnly Property RepositionEditingControlOnValueChange() _
         As Boolean Implements _
         IDataGridViewEditingControl.RepositionEditingControlOnValueChange
 
         Get
             Return False
         End Get
 
     End Property
 
     Public Property EditingControlDataGridView() As DataGridView _
         Implements IDataGridViewEditingControl.EditingControlDataGridView
 
         Get
             Return dataGridViewControl
         End Get
         Set(ByVal value As DataGridView)
             dataGridViewControl = value
         End Set
 
     End Property
 
     Public Property EditingControlValueChanged() As Boolean _
         Implements IDataGridViewEditingControl.EditingControlValueChanged
 
         Get
             Return valueIsChanged
         End Get
         Set(ByVal value As Boolean)
             valueIsChanged = value
         End Set
 
     End Property
 
     Public ReadOnly Property EditingControlCursor() As Cursor _
         Implements IDataGridViewEditingControl.EditingPanelCursor
 
         Get
             Return MyBase.Cursor
         End Get
 
     End Property
 
     Protected Overrides Sub OnValueChanged(ByVal eventargs As EventArgs)
 
         ' Notify the DataGridView that the contents of the cell have changed.
         valueIsChanged = True
         Me.EditingControlDataGridView.NotifyCurrentCellDirty(True)
MyBase.OnValueChanged(eventargs)
 
     End Sub
 
 End Class
Espero le sea de ultilidad a alguien como lo fue para mi...

No se olviden de calificar el tema por fas ...
__________________
L.C.I. Juan Jesús

--- El sabio no dice nunca todo lo que piensa, pero siempre piensa todo lo que dice. ---
juanutcm está desconectado   Responder Citando
Antiguo 21-feb-2008, 05:21   #6 (permalink)
granchop ha deshabilitado el karma
 
Fecha de Ingreso: febrero-2008
Mensajes: 2
Re: DateTimePicker en DataGridView

Estoy seguier el ejemplo anterior pero empleando en este caso un control propico en concreto una caja de texto. El caso esque todo correcto pero cuando agrego un datagridview e intento acceder a las propiedades de la mi control caja de texto no tengo forma de conseguirlo.

Si me pudieran ayudar me seria de gran ayuda.
granchop está desconectado   Responder Citando
Antiguo 21-feb-2008, 07:24   #7 (permalink)
juanutcm está en el buen camino
 
Avatar de juanutcm
 
Fecha de Ingreso: marzo-2005
Mensajes: 194
Enviar un mensaje por MSN a juanutcm
Re: DateTimePicker en DataGridView

Por que no pones el codigo para poder darnos una idea mas clara y asi poder ayudarte con tu situacion.
__________________
L.C.I. Juan Jesús

--- El sabio no dice nunca todo lo que piensa, pero siempre piensa todo lo que dice. ---
juanutcm está desconectado   Responder Citando
Antiguo 25-feb-2008, 02:05   #8 (permalink)
granchop ha deshabilitado el karma
 
Fecha de Ingreso: febrero-2008
Mensajes: 2
Re: DateTimePicker en DataGridView

Código:
Public Class EditValCeldacTexto
    Inherits NetControlsAsr.cTexto
    Implements IDataGridViewEditingControl


    Private nNumeroFila As Integer
    Private oDGV As DataGridView
    Private bValorCambiado As Boolean = False


    Public Property EditingControlDataGridView() As System.Windows.Forms.DataGridView Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlDataGridView
        Get
            Return oDGV
        End Get
        Set(ByVal value As System.Windows.Forms.DataGridView)
            oDGV = value
        End Set
    End Property

    Public Property EditingControlFormattedValue() As Object Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlFormattedValue
        Get
            Return Me.Text
        End Get
        Set(ByVal value As Object)
            Me.Text = value
        End Set
    End Property

    Public Property EditingControlRowIndex() As Integer Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlRowIndex
        Get
            Return Me.nNumeroFila
        End Get
        Set(ByVal value As Integer)
            Me.nNumeroFila = value
        End Set
    End Property

    Public Property EditingControlValueChanged() As Boolean Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlValueChanged
        Get
            Return Me.bValorCambiado
        End Get
        Set(ByVal value As Boolean)
            Me.bValorCambiado = value
        End Set
    End Property

    Public ReadOnly Property EditingPanelCursor() As System.Windows.Forms.Cursor Implements System.Windows.Forms.IDataGridViewEditingControl.EditingPanelCursor
        Get
            Return MyBase.Cursor
        End Get
    End Property

    Public ReadOnly Property RepositionEditingControlOnValueChange() As Boolean Implements System.Windows.Forms.IDataGridViewEditingControl.RepositionEditingControlOnValueChange
        Get
            Return False
        End Get
    End Property

    Public Sub ApplyCellStyleToEditingControl(ByVal dataGridViewCellStyle As System.Windows.Forms.DataGridViewCellStyle) Implements System.Windows.Forms.IDataGridViewEditingControl.ApplyCellStyleToEditingControl

        Me.Font = dataGridViewCellStyle.Font
        Me.ForeColor = dataGridViewCellStyle.ForeColor
        Me.BackColor = dataGridViewCellStyle.BackColor

    End Sub

    Public Function EditingControlWantsInputKey(ByVal keyData As System.Windows.Forms.Keys, ByVal dataGridViewWantsInputKey As Boolean) As Boolean Implements System.Windows.Forms.IDataGridViewEditingControl.EditingControlWantsInputKey
        Select Case keyData And Keys.KeyCode
            Case Keys.Left, Keys.Up, Keys.Down, Keys.Right, _
         Keys.Home, Keys.End, Keys.PageDown, Keys.PageUp

                Return True
            Case Else
                Return False
        End Select

    End Function

    Public Function GetEditingControlFormattedValue(ByVal context As System.Windows.Forms.DataGridViewDataErrorContexts) As Object Implements System.Windows.Forms.IDataGridViewEditingControl.GetEditingControlFormattedValue
        'Return Me.Value.ToString("dd-MM-yyyy")
        Return Me.Text
    End Function

    Protected Overrides Sub OnTextChanged(ByVal e As System.EventArgs)
        bValorCambiado = True
        Me.EditingControlDataGridView.NotifyCurrentCellDirty(True)
        MyBase.OnTextChanged(e)
    End Sub

    Public Sub PrepareEditingControlForEdit(ByVal selectAll As Boolean) Implements System.Windows.Forms.IDataGridViewEditingControl.PrepareEditingControlForEdit

    End Sub

End Class
aqui es donde heredo de mi caja de texto con su comportamiento y demas.
Código:
Public Class ColumnacTexto
    Inherits System.Windows.Forms.DataGridViewColumn

    'Declaracion de Variables Internas
    Private _Longitud As Integer
    Private _Formato As tbFormatos
    Private _Decimales As Byte
    Private _SeparadorDec As Char
    Private _UserValues As String

    Public Overrides Property CellTemplate() As System.Windows.Forms.DataGridViewCell
        Get
            Return MyBase.CellTemplate
        End Get
        Set(ByVal value As System.Windows.Forms.DataGridViewCell)
            MyBase.CellTemplate = value
        End Set
    End Property

    Public Property Decimales() As Byte
        Get
            Return Me._Decimales
        End Get
        Set(ByVal Value As Byte)
            Me._Decimales = Value
        End Set
    End Property

    Public Property Longitud() As Integer
        Get
            Return Me._Longitud
        End Get
        Set(ByVal value As Integer)
            Me._Longitud = value
        End Set
    End Property

    Public Property SeparadorDec() As Char
        Get
            Return Me._SeparadorDec
        End Get
        Set(ByVal Value As Char)
            If Value = "." OrElse Value = "," Then
                Me._SeparadorDec = Value
            End If
        End Set
    End Property

    Public Property Formato() As tbFormatos
        Get
            Return Me._Formato
        End Get
        Set(ByVal value As tbFormatos)
            Me._Formato = value
        End Set
    End Property

    Public Property UserValues() As String
        Get
            Return Me._UserValues
        End Get
        Set(ByVal Value As String)
            Me._UserValues = Value
        End Set
    End Property

    Public Sub New()
        MyBase.New(New CeldacTexto())

    End Sub
End Class
en la clase de la columna un pequeño problemilla tengo que implementar todas las propiedades que me interesen de la caja de texto pero bueno seguimos

Código:
Public Class CeldacTexto

#Region "Propiedades SobreEscritas"

    Public Overrides ReadOnly Property EditType() As System.Type
        Get
            Return GetType(EditValCeldacTexto)
        End Get
    End Property

    Public Overrides ReadOnly Property ValueType() As System.Type
        Get
            Return GetType(String)
        End Get
    End Property

    Public Overrides ReadOnly Property DefaultNewRowValue() As Object
        Get
            Return ""
        End Get
    End Property

#End Region

#Region "Metos Sobreescritos"

    Public Overrides Sub InitializeEditingControl(ByVal rowIndex As Integer, ByVal initialFormattedValue As Object, ByVal dataGridViewCellStyle As DataGridViewCellStyle)
        'MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle)

        Dim ctlEditorValorCelda As EditValCeldacTexto = CType(DataGridView.EditingControl, EditValCeldacTexto)
        Dim colPerso As ColumnacTexto = CType(Me.OwningColumn, ColumnacTexto)

        ctlEditorValorCelda.Decimales = colPerso.Decimales
        ctlEditorValorCelda.Longitud = colPerso.Longitud
        ctlEditorValorCelda.SeparadorDec = colPerso.SeparadorDec
        ctlEditorValorCelda.Formato = colPerso.Formato
        ctlEditorValorCelda.UserValues = colPerso.UserValues
        ctlEditorValorCelda.Text = initialFormattedValue

        MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle)

    End Sub

#End Region

End Class
como veis en el Public Overrides Sub InitializeEditingControl creo las variables del editor y la columna que quiero usar y les paso las propiedades vale hasta aqui todo bien mi primer problema fue que la instruccion MyBase.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle) se encontraba al principio del metodo con lo cual la primera fila que se insertaba no obtenia la propiedades que le establecia si no las que tenia pordefecto la caja de texto bie en el form cargo es siguiente codigo para establecer las propiedades de la columna
Código:
        Dim oMCCol As New NetControlsAsr.ColumnacTexto()
        Dim oMCCol2 As New NetControlsAsr.ColumnacTexto()

        oMCCol.Width = 80
        oMCCol.Longitud = 5
        oMCCol.Formato = NetControlsAsr.tbFormatos.Enteros
        oMCCol.HeaderText = "Longitud 5"

        oMCCol2.Width = 80
        oMCCol2.Longitud = 3
        oMCCol.Formato = NetControlsAsr.tbFormatos.Enteros
        oMCCol2.HeaderText = "Longitud 3"

        Me.DataGridView1.Columns.Add(oMCCol)
        Me.DataGridView1.Columns.Add(oMCCol2)
        Me.DataGridView1.Rows.Add(4)
Hasta ahora todo bien pero en el momento que utilizo el diseñador de visual estudio Ejemplo. Boton derecho sobre el grid agregar columnas agrego la mia cuando por ejemplo en la propiedad longitud establezco 6 no almacena el valor lo deja como se inicializo no se si me explico bien un saludo y Muchas gracias
granchop está desconectado   Responder Citando
Respuesta

Calificación: Calificación de Tema: 1 votos, 5,00 de promedio.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 03:23.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93