 
			
				17/11/2014, 13:57
			
			
			     |  
      |    |    |    Fecha de Ingreso: noviembre-2014  
						Mensajes: 1
					  Antigüedad: 11 años Puntos: 0     |        |  
  |      El índice estaba fuera del intervalo.        Tengo este error en mi programa que estoy haciendo, tengo otros 4 formularios iguales pero no se porque en este me esta saliendo el error: 
El índice estaba fuera del intervalo. Debe ser un valor no negativo e inferior al tamaño de la colección. Nombre del parametro: index   
Aca les dejo la parte de mi formulario   
__________________________________________________  _________________   
Public Class FromProductos 
    Private dt As New DataTable 
    Private Sub FromProductos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
        mostrar() 
    End Sub 
    Public Sub limpiar() 
        btnguardar.Visible = True 
        btnEditar.Visible = False 
        txtID.Text = "" 
        txtmarca.Text = "" 
        txtnomMarca.Text = "" 
        txtgeneracion.Text = "" 
        txtTipo.Text = "" 
        txtprecio.Text = "" 
    End Sub   
    Private Sub mostrar() 
        Try 
            Dim func As New fproducto 
            dt = func.mostrar 
            DataListado.Columns.Item("Eliminar").Visible = False     
            If dt.Rows.Count <> 0 Then 
                DataListado.DataSource = dt 
                txtBuscar.Enabled = True 
                DataListado.ColumnHeadersVisible = True 
                inexistente.Visible = False 
            Else 
                DataListado.DataSource = Nothing 
                txtBuscar.Enabled = False 
                DataListado.ColumnHeadersVisible = False 
                inexistente.Visible = True 
            End If 
            btnAceptar.Visible = True 
            btnEditar.Visible = False 
            buscar()     
        Catch ex As Exception 
            MsgBox(ex.Message)   
        End Try   
    End Sub 
    Private Sub buscar() 
        Try 
            Dim ds As New DataSet 
            ds.Tables.Add(dt.Copy) 
            Dim dv As New DataView(ds.Tables(0))     
            dv.RowFilter = cboCampo.Text & " like '" & txtBuscar.Text & "%'"   
            If dv.Count <> 0 Then 
                inexistente.Visible = False 
                DataListado.DataSource = dv 
                ocultar_columnas()   
            Else 
                inexistente.Visible = True 
                DataListado.DataSource = Nothing 
            End If   
        Catch ex As Exception 
            MsgBox(ex.Message)   
        End Try 
    End Sub 
    Private Sub ocultar_columnas()   
    End Sub   
    Private Sub btnguardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnguardar.Click 
        Try 
            If Me.ValidateChildren = True And txtID.Text <> "" And txtmarca.Text <> "" And txtnomMarca.Text <> "" And txtgeneracion.Text <> "" And txtprecio.Text <> "" And txtTipo.Text <> "" Then   
                Dim dts As New vproducto 
                Dim func As New fproducto   
                dts.gidproducto = txtID.Text 
                dts.gidmarca = txtmarca.Text 
                dts.ggeneracion = txtgeneracion.Text 
                dts.gprecio = txtprecio.Text 
                dts.gidalmacen = txtTipo.Text   
                If func.insertar(dts) Then 
                    MessageBox.Show("Producto registrado correctamente", "Guardando datos", MessageBoxButtons.OK, MessageBoxIcon.Information) 
                    mostrar() 
                    limpiar() 
                    cargar_detalle() 
                Else 
                    MessageBox.Show("Producto no registrado correctamente", "Guardando datos", MessageBoxButtons.OK, MessageBoxIcon.Error) 
                    mostrar()   
                    limpiar() 
                End If 
            Else 
                MessageBox.Show("Falta ingresar algunos datos", "Guardando datos", MessageBoxButtons.OK, MessageBoxIcon.Information) 
            End If 
        Catch ex As Exception 
            MsgBox(ex.Message) 
        End Try 
    End Sub   
    Private Sub DataListado_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataListado.CellClick 
        Try 
            txtID.Text = DataListado.SelectedCells.Item(1).Value 
            txtmarca.Text = DataListado.SelectedCells.Item(2).Value 
            txtnomMarca.Text = DataListado.SelectedCells.Item(3).Value 
            txtTipo.Text = DataListado.SelectedCells.Item(4).Value 
            txtgeneracion.Text = DataListado.SelectedCells.Item(5).Value 
            txtprecio.Text = DataListado.SelectedCells.Item(6).Value 
        Catch ex As Exception 
            MsgBox(ex.Message) 
        End Try 
    End Sub   
    Private Sub DataListado_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataListado.CellContentClick 
        Try 
            If e.ColumnIndex = Me.DataListado.Columns.Item("Eliminar").Index Then 
                Dim chkcell As DataGridViewCheckBoxCell = Me.DataListado.Rows(e.RowIndex).Cells("Eliminar") 
                chkcell.Value = Not chkcell.Value 
            End If 
        Catch ex As Exception 
            MsgBox(ex.Message) 
        End Try 
    End Sub 
    Private Sub btnEditar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditar.Click 
        Try 
            Dim result As DialogResult   
            result = MessageBox.Show("Realmente desea editar los datos de la venta?", "MOdificando registros", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)   
            If result = DialogResult.OK Then   
                If Me.ValidateChildren = True And txtID.Text <> "" And txtmarca.Text <> "" And txtnomMarca.Text <> "" And txtgeneracion.Text <> "" And txtprecio.Text <> "" And txtTipo.Text <> "" Then 
                    Try 
                        Dim dts As New vproducto 
                        Dim func As New fproducto   
                        dts.gidproducto = txtID.Text 
                        dts.gidmarca = txtmarca.Text 
                        dts.ggeneracion = txtgeneracion.Text 
                        dts.gprecio = txtprecio.Text 
                        dts.gidalmacen = txtprecio.Text   
                        If func.editar(dts) Then 
                            MessageBox.Show("Producto modficado correctamente", "Modificado registros", MessageBoxButtons.OK, MessageBoxIcon.Information) 
                            mostrar() 
                            limpiar() 
                        Else 
                            MessageBox.Show("Producto no fue modifcada intente de nuevo", "Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Error) 
                            mostrar() 
                            limpiar() 
                        End If   
                    Catch ex As Exception 
                        MsgBox(ex.Message) 
                    End Try 
                Else 
                    MessageBox.Show("Falta ingresar algunos datos", "Modificando registros", MessageBoxButtons.OK, MessageBoxIcon.Information) 
                End If 
            End If 
        Catch ex As Exception 
            MsgBox(ex.Message) 
        End Try 
    End Sub   
    Private Sub cbeliminar_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbEliminar.CheckedChanged 
        Try 
            If cbEliminar.CheckState = CheckState.Checked Then 
                DataListado.Columns.Item("Eliminar").Visible = True 
            Else 
                DataListado.Columns.Item("Eliminar").Visible = False 
            End If 
        Catch ex As Exception 
            MsgBox(ex.Message) 
        End Try 
    End Sub   
    Public Sub cargar_detalle() 
        Try     
        FormAgregarMarca.txtID.Text = DataListado.SelectedCells.Item(1).Value 
        FormAgregarMarca.txtmarca.Text = DataListado.SelectedCells.Item(2).Value 
        FormAgregarMarca.txtnomMarca.Text = DataListado.SelectedCells.Item(3).Value 
        FormAgregarMarca.txtgeneracion.Text = DataListado.SelectedCells.Item(4).Value 
        FormAgregarMarca.txtTipo.Text = DataListado.SelectedCells.Item(5).Value 
        FormAgregarMarca.txtTipo.Text = DataListado.SelectedCells.Item(6).Value   
            FormAgregarMarca.ShowDialog() 
        Catch ex As Exception 
            MsgBox(ex.Message) 
        End Try 
    End Sub 
    Private Sub txtbuscar_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtBuscar.TextChanged 
        buscar() 
    End Sub     
    Private Sub btnAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAceptar.Click 
        limpiar() 
        mostrar()   
    End Sub 
    Private Sub btnAlmacen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAlmacen.Click 
        FormAlmacen.txtflag.Text = "1" 
        FormAlmacen.ShowDialog() 
    End Sub 
    Private Sub btnMarca_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMarca.Click 
        FormMarca.txtflag.Text = "1" 
        FormMarca.ShowDialog() 
    End Sub   
End Class           |