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

Problema datagridview

Estas en el tema de Problema datagridview en el foro de .NET en Foros del Web. Hola gente como estan, bueno yo aca rompiendome el melon pensando porque no funciona, e aqui el codigo en vb.net If Me._TipoDeListado = "Alta" Then ...
  #1 (permalink)  
Antiguo 18/07/2012, 23:17
 
Fecha de Ingreso: julio-2012
Ubicación: Avellaneda
Mensajes: 3
Antigüedad: 11 años, 9 meses
Puntos: 0
Desacuerdo Problema datagridview

Hola gente como estan, bueno yo aca rompiendome el melon pensando porque no funciona, e aqui el codigo en vb.net

If Me._TipoDeListado = "Alta" Then
For i As Integer = 0 To Me._dataSetDelListado.Tables("Empleado").Rows.Coun t - 1

If CBool(Me._dataSetDelListado.Tables("Empleado").Row s(i)("Alta").ToString) = True Then
If i = 0 Then
Me.dgvListado.CurrentCell = Nothing
Me.dgvListado.Rows(i).Visible = False

Else
Me.dgvListado.Rows(i).Visible = False

End If

End If
Next
End If

En fin, cuando deebagueo, pasa por el metodo invisible y pone esa fila en invisible, pero de todas maneras me la muestra en el datagridview
No se como hacer o que estoy haciendo mal.
Me pueden dar una mano, se los agradeceria.
  #2 (permalink)  
Antiguo 18/07/2012, 23:30
Avatar de JxDarkAngel  
Fecha de Ingreso: septiembre-2009
Mensajes: 82
Antigüedad: 14 años, 7 meses
Puntos: 2
Respuesta: Problema datagridview

Para poder ocultarla, primero tienes que romper el enlace que existe entre tu Datagridview y el DataSource

Haz lo siguiente al momento de querer ocultar la fila:

Dim cm As CurrencyManager = DirectCast(BindingContext(dgvEmpleados.DataSource) , CurrencyManager)

cm.SuspendBinding()

dgvEmpleados.Rows(i).Visible = False

cm.ResumeBinding()
  #3 (permalink)  
Antiguo 19/07/2012, 05:32
 
Fecha de Ingreso: julio-2012
Ubicación: Avellaneda
Mensajes: 3
Antigüedad: 11 años, 9 meses
Puntos: 0
Respuesta: Problema datagridview

Muchisimas gracias lo voy a probar, pero me podrias decir porque no pasa eso con las columnas.
  #4 (permalink)  
Antiguo 19/07/2012, 14:45
 
Fecha de Ingreso: julio-2012
Ubicación: Avellaneda
Mensajes: 3
Antigüedad: 11 años, 9 meses
Puntos: 0
Respuesta: Problema datagridview

Se siguen mostrando las filas no entiendo porque no lo hace, a ver si pueden sacar cual es el error, que estoy cometiendo.

Les mando el codigo completo de la clase del formulario

Public Class FrmListado
Private _bSourceDelListado As BindingSource
'Private _dataViewManagerDelListado As DataViewManager
Private _dataSetDelListado As DataSet
Private _TipoDeListado As String


Public Sub New(ByVal TipoDeListado As String)

' Llamada necesaria para el Diseñador de Windows Forms.
InitializeComponent()
Me._TipoDeListado = TipoDeListado
' Agregue cualquier inicialización después de la llamada a InitializeComponent().

End Sub
Private Sub FrmListado_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Icon = My.Resources.ÍconoAcp

Me._dataSetDelListado = _delegadoTDS.Invoke()
Me._bSourceDelListado = New BindingSource

Me._bSourceDelListado.DataSource = Me._dataSetDelListado
Me._bSourceDelListado.DataMember = "Empleado"

Me.dgvListado.DataSource = Me._bSourceDelListado

Call ConfigurarDGView()

End Sub

Public Sub ConfigurarDGView()

dgvListado.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill
dgvListado.EnableHeadersVisualStyles = True

REM seteo el formato del encabezado
dgvListado.RowHeadersDefaultCellStyle.BackColor = Color.Aqua
dgvListado.RowHeadersDefaultCellStyle.ForeColor = Color.Lavender
dgvListado.RowHeadersVisible = False
dgvListado.ColumnHeadersVisible = True

REM doy formato a las filas
dgvListado.RowsDefaultCellStyle.BackColor = Color.MediumSeaGreen
dgvListado.RowsDefaultCellStyle.ForeColor = Color.GhostWhite

With dgvListado

.SelectionMode = DataGridViewSelectionMode.FullRowSelect
.EditMode = DataGridViewEditMode.EditProgrammatically

.AllowUserToAddRows = False
.AllowUserToDeleteRows = True
.AllowUserToResizeColumns = True
.AllowUserToResizeRows = True
.Anchor = AnchorStyles.Top Or AnchorStyles.Left Or AnchorStyles.Right
.BackgroundColor = Color.DarkGray
.BorderStyle = BorderStyle.Fixed3D
.CellBorderStyle = DataGridViewCellBorderStyle.Sunken
.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.Sunken
.ColumnHeadersDefaultCellStyle.BackColor = Color.Azure
.DefaultCellStyle.BackColor = Color.Cyan


End With

dgvListado.ColumnHeadersDefaultCellStyle.BackColor = Color.Black
dgvListado.ColumnHeadersDefaultCellStyle.ForeColor = Color.White
dgvListado.GridColor = Color.Red


For i As Integer = 0 To Me.dgvListado.Columns.Count - 1
If Not i = 0 And Not i = 1 And Not i = 12 Then
Me.dgvListado.Columns(i).Visible = False
End If
Next

If Me._TipoDeListado = "Alta" Then

Dim cm As CurrencyManager = DirectCast(BindingContext(Me.dgvListado.DataSource ), CurrencyManager)

For i As Integer = 0 To Me._dataSetDelListado.Tables("Empleado").Rows.Coun t - 1

If CBool(Me._dataSetDelListado.Tables("Empleado").Row s(i)("Alta").ToString) = True Then
If i = 0 Then
Me.dgvListado.CurrentCell = Nothing
'Me.dgvListado.Rows(i).Visible = False
'Para poder ocultarla, primero tienes que romper el enlace que existe entre tu Datagridview y el DataSource
'Haz lo siguiente al momento de querer ocultar la fila:

cm.SuspendBinding()

Me.dgvListado.Rows(i).Visible = False

cm.ResumeBinding()
Else

cm.SuspendBinding()

Me.dgvListado.Rows(i).Visible = False

cm.ResumeBinding()

End If

End If
Next
End If
end class

Etiquetas: datagridview, net, vb
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 04:59.