Advertisement
jsbsan

gridview

Oct 16th, 2014
3,688
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GAMBAS 1.63 KB | None | 0 0
  1. ' Gambas class file
  2.  
  3. Public Sub _new()
  4.  
  5. End
  6.  
  7. Public Sub Form_Open()
  8.  
  9.   GridView1.mode = Select.Single
  10.   definir()
  11.   relleno()
  12.  
  13. End
  14.  
  15. Public Sub definir()
  16.  
  17.   With GridView1
  18.     .header = 3
  19.     .rows.count = 7
  20.     .columns.count = 7
  21.     .Columns[0].title = "Columna 1"
  22.     .Columns[1].title = "Columna 2"
  23.     .Columns[2].title = "Columna 3"
  24.     .Columns[3].title = "Columna 4"
  25.     .Columns[4].title = "Columna 5"
  26.     .Columns[5].title = "Columna 6"
  27.     .Columns[6].title = "Columna 7"
  28.     .Columns[0].width = 50
  29.     .Columns[1].width = 60
  30.     .Columns[2].width = 60
  31.     .Columns[3].width = 60
  32.     .Columns[4].width = 60
  33.     .Columns[5].width = 60
  34.     .Columns[6].width = 118
  35.     .font.name = "Times"
  36.     .font.size = 9
  37.     .Background = 16777215
  38.     .Foreground = 0
  39.   End With
  40.  
  41. End
  42.  
  43.  
  44. Public Sub relleno()
  45.  
  46.   Dim a, b As Integer
  47.  
  48.   For a = 0 To GridView1.Rows.Max
  49.     For b = 0 To GridView1.Columns.Max
  50.       GridView1[a, b].text = Str$(a) & " " & Str$(b)
  51.     Next
  52.   Next
  53.  
  54. End
  55.  
  56. Public Sub GridView1_Click()
  57.  
  58.   Dim fila, columna As Integer
  59.   'aumentar fila
  60.   GridView1.Rows.count += 1
  61.  
  62.   If GridView1.Rows.Selection.count = 0 Then
  63.     Message.Info("Tienes que seleccionar una fila")
  64.   Endif
  65.  
  66.   For fila = GridView1.Rows.Max To GridView1.Rows.Selection[0] Step -1
  67.  
  68.     For columna = 0 To GridView1.Columns.Max
  69.  
  70.       If fila - 1 > 0 Then GridView1[fila, columna].text = GridView1[fila - 1, columna].text
  71.  
  72.     Next
  73.  
  74.   Next
  75.  
  76.   'elimino textos de la fila que acabo de añadir
  77.   For columna = 0 To GridView1.Columns.Max
  78.  
  79.     GridView1[GridView1.Rows.Selection[0], columna].text = ""
  80.  
  81.   Next
  82.  
  83. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement