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

DatagridView selecionar línea

Estas en el tema de DatagridView selecionar línea en el foro de .NET en Foros del Web. tengo un datagridview y me gustaría seleccionar una linea especifica de ella pero por código.. como lo puedo hacer ? intenté con Código: DataGridView.Rows.IndexOf = ...
  #1 (permalink)  
Antiguo 27/07/2011, 10:19
 
Fecha de Ingreso: junio-2011
Ubicación: España
Mensajes: 32
Antigüedad: 12 años, 9 meses
Puntos: 0
DatagridView selecionar línea

tengo un datagridview y me gustaría seleccionar una linea especifica de ella pero por código.. como lo puedo hacer ?

intenté con

Código:
DataGridView.Rows.IndexOf = numLinea
pero no me vá

Gracias.
  #2 (permalink)  
Antiguo 27/07/2011, 11:33
Avatar de HaverRamirez  
Fecha de Ingreso: junio-2011
Ubicación: Guatemala
Mensajes: 273
Antigüedad: 12 años, 8 meses
Puntos: 33
Respuesta: DatagridView selecionar línea

me.grdView.rows(rw)(cl).tostring
donde rw es row
y cl es columna
  #3 (permalink)  
Antiguo 27/07/2011, 13:05
 
Fecha de Ingreso: junio-2011
Ubicación: España
Mensajes: 32
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: DatagridView selecionar línea

gracias por la ayuda.
si repartir esa información para unos TextBox como puedo hacer ?
  #4 (permalink)  
Antiguo 27/07/2011, 14:02
Avatar de HaverRamirez  
Fecha de Ingreso: junio-2011
Ubicación: Guatemala
Mensajes: 273
Antigüedad: 12 años, 8 meses
Puntos: 33
Respuesta: DatagridView selecionar línea

Binding

http://www.elguille.info/colabora/NET2005/Percynet_EnlaceDatos_ParteI.htm
http://www.elguille.info/colabora/NET2005/aderojas_bindingcheckbox.htm
http://msdn.microsoft.com/en-us/magazine/cc164106.aspx
http://visualbasic-source-code.com/2010/06/visual-basic-net-binding-windows-forms-controls.html
  #5 (permalink)  
Antiguo 27/07/2011, 15:20
 
Fecha de Ingreso: junio-2011
Ubicación: España
Mensajes: 32
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: DatagridView selecionar línea

gracias por la respuesta.. la verdad es que he intentado el método de binding antes pero tuve malas experiencias.

no hay manera de seleccionar solo la línea, no para alguna variable ni nada, solo seleccionarla como si fuera el usuario a poner el ratón encima y hacer 1 click.

Código:
Dim lastRow As Integer = DGV.RowCount - 1
        
        editar.Show()
        editar.txtID.Text = DGV.CurrentRow.Cells(0).Value.ToString

        editar.txtID.Text = DGV.Rows(lastRow).Cells(0).Value.ToString

        editar.txtCodigo.Text = DGV.Rows(lastRow).Cells(1).Value.ToString
        editar.txtDesc.Text = DGV.Rows(lastRow).Cells(2).Value.ToString
        editar.txtData.Text = DGV.Rows(lastRow).Cells(3).Value.ToString
        editar.txtPercentagem.Text = DGV.Rows(lastRow).Cells(4).Value.ToString
        editar.txtMedia.Text = DGV.Rows(lastRow).Cells(5).Value.ToString
si hago como ahí me salta el error:
System.NullReferenceException - {"Object reference not set to an instance of an object."}


ya probé com:
Código:
DGV.Rows(lastRow).Selected = True
pero tampoco me fue >_>

perdon por estar insistiendo ^^'
  #6 (permalink)  
Antiguo 27/07/2011, 15:31
Avatar de HaverRamirez  
Fecha de Ingreso: junio-2011
Ubicación: Guatemala
Mensajes: 273
Antigüedad: 12 años, 8 meses
Puntos: 33
Respuesta: DatagridView selecionar línea

Primero verifica que se este seleccionando una fila y columan

si no existe la fila 4 da error
me.grdView.datasource.rows(4)

si no existe la columan 5 da error
me.grdView.datasource.rows(4)(5)


Seleccionar

dataGrid1.CurrentCell = New DataGridCell(NoRow, NoColumn)
dataGrid1.Select(hti.Row)
  #7 (permalink)  
Antiguo 29/07/2011, 04:06
 
Fecha de Ingreso: junio-2011
Ubicación: España
Mensajes: 32
Antigüedad: 12 años, 9 meses
Puntos: 0
Respuesta: DatagridView selecionar línea

gracias por la ayuda =D

Etiquetas: datagridview, selecionar
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 18:02.