Visual Basic.NET - Seleccionar fila en un datagrid

 
Vista:

Seleccionar fila en un datagrid

Publicado por Fernando (9 intervenciones) el 26/09/2006 13:41:28
Estimados: tengo el siguiente codigo

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dad.Fill(dse, "cliiva")
DataGrid1.DataSource = dse
DataGrid1.DataMember = "cliiva"
DataGrid1.ReadOnly = True
DataGrid1.TableStyles.Clear()
Dim estilo As New DataGridTableStyle()
estilo.MappingName = dse.Tables(0).TableName
estilo.AlternatingBackColor = Color.Bisque
Dim textcol1 As New DataGridTextBoxColumn()
textcol1.MappingName = "nomcliente"
textcol1.HeaderText = "Nombre del cliente"
textcol1.Width = 100
textcol1.TextBox.ForeColor = DataGrid1.SelectionForeColor
textcol1.TextBox.BackColor = DataGrid1.SelectionBackColor
AddHandler textcol1.TextBox.Enter, New EventHandler(AddressOf TextBox_Enter)
estilo.GridColumnStyles.Add(textcol1)
Dim textcol2 As New DataGridTextBoxColumn()
textcol2.MappingName = "nomiva"
textcol2.HeaderText = "Situacion impositiva"
textcol2.Width = 150
textcol2.TextBox.ForeColor = DataGrid1.SelectionForeColor
textcol2.TextBox.BackColor = DataGrid1.SelectionBackColor
AddHandler textcol2.TextBox.Enter, New EventHandler(AddressOf TextBox_Enter)
estilo.GridColumnStyles.Add(textcol2)
Dim checkbox1 As New DataGridBoolColumn()
checkbox1.MappingName = "prueba"
checkbox1.HeaderText = "prueba"
checkbox1.Width = 100
checkbox1.ReadOnly = False
estilo.GridColumnStyles.Add(checkbox1)
DataGrid1.TableStyles.Add(estilo)
DataGrid1.Select(DataGrid1.CurrentRowIndex)

End Sub

Private Sub DataGrid1_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGrid1.CurrentCellChanged
DataGrid1.Select(DataGrid1.CurrentRowIndex)
End Sub

Private Sub TextBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs)
DataGrid1.Focus()
DataGrid1.Select(DataGrid1.CurrentRowIndex)
End Sub

Lo que intento hacer es desplazarme con las teclas de flecha por la grilla y que quede sombreada la fila completa, y hasta ahi lo logré. El problema se me presenta que al estar en la primera columna de la primera fila, si presiono la tecla de flecha derecha me queda sombreada solamente esa celda en lugar de toda la fila. Lo mismo me ocurre cuando estoy posicionado en la última columna de la última fila.
Hasta ahora no encontré ninguna solución a este problema.
Desde ya, muchas gracias.

Fernando.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder