https://foro.gambas-es.org/viewtopic.php?f=4&t=2139&p=12352#p12352
-----------------------------------
jsbsan
Miercoles, 25 Enero 2012, 17:29

Re: Gridview Editable?
-----------------------------------
Prueba con TableView, es un control igual que el Gridview, pero editable.

Simplemente tendras que añadirle, que cuando el usuario pulse "Enter" o "Return" en la ultima fila y ultima columnas, le añada una fila mas al tableview. (usa el evento keypress) y se posicione el cursor  en esa nueva fila, en la columna primera.

Este es parte del codigo que te puede orientar:
[code linenumbers=false syntax=gambas]PUBLIC ultimafila AS Integer

PUBLIC SUB _new()
GridView1.Rows.count = 1
GridView1.Columns.count = 2
GridView1.mode = 1
ultimafila = GridView1.Rows.count

END

PUBLIC SUB Form_Open()

END

PUBLIC SUB GridView1_Click()

  IF GridView1.row = ultimafila - 1 THEN 
    gridview1.Rows.count += 1
    ultimafila = gridview1.Rows.count
    GridView1.Moveto(ultimafila - 1, 0)
ENDIF 
END
[/code]


nota:
De echo buscando en el codigo fuente del gambas (gambas2-2.23.1/comp/src/gb.form/TableView.class), encontre como añadia las funciones de edicion al gridviews:

[code linenumbers=false syntax=gambas]' Gambas class file

INHERITS GridView
EXPORT 

EVENT Save(Row AS Integer, Column AS Integer, Value AS String)
EVENT Insert
EVENT Click

PRIVATE $hTextBox AS TextBox
PRIVATE $hComboBox AS ComboBox
PRIVATE $hEditor AS Object
PRIVATE $bTextBox AS Boolean

PRIVATE $iCol AS Integer
PRIVATE $iRow AS Integer
PRIVATE $hWatcher AS Watcher

PUBLIC SUB _new()
  
  DIM hObs AS Observer
  
  hObs = NEW Observer(ME) AS "GridView"
  $hWatcher = NEW Watcher(ME) AS "GridView"
  
  $hComboBox = NEW ComboBox(ME.Window) AS "Editor"
  $hComboBox.Ignore = TRUE
  $hComboBox.Hide

  $hTextBox = NEW TextBox(ME.Window) AS "Editor"
  $hTextBox.Ignore = TRUE
  $hTextBox.Border = FALSE
  $hTextBox.Hide

END

PRIVATE SUB SaveEditor()
  
  DIM sText AS String 
  
  IF NOT $hEditor THEN RETURN
  
  sText = $hEditor.Text
  
  IF sText = ME[$iRow, $iCol].Text THEN RETURN
  RAISE Save($iRow, $iCol, sText)
  ME[$iRow, $iCol].Refresh
  
END

PUBLIC SUB Save()
  
  HideEditor
  
END

PUBLIC SUB Cancel()
  
  HideEditor(TRUE)
  
END

PRIVATE SUB HideEditor(OPTIONAL bNoSave AS Boolean)
  
  IF $hEditor THEN
    IF NOT bNoSave THEN SaveEditor 
    $hEditor.Hide
    $hEditor = NULL
  ENDIF
  
END

PRIVATE SUB MoveEditor()
  
  DIM X, Y AS Integer
  
  IF NOT $hEditor THEN RETURN 
  
  X = ME.ScreenX - ME.Window.ScreenX
  Y = ME.ScreenY - ME.Window.ScreenY - ME.Window.ClientY
  'DEBUG $iRow;; $iCol
  WITH ME[$iRow, $iCol]
    X += .X
    Y += .Y
    $hEditor.Move(X, Y, .Width, .Height)
  END WITH
  'DEBUG
  $hEditor.Font = ME.Font
  $hEditor.Show
  'DEBUG 
  
END


PUBLIC SUB GridView_MouseDown()
  
  HideEditor
  
END


PUBLIC SUB GridView_RowResize(Row AS Integer)
  
  HideEditor
  
END


PUBLIC SUB GridView_ColumnResize(Column AS Integer)
  
  HideEditor
  
END


PUBLIC SUB GridView_Scroll()
  
  HideEditor
  
END


PUBLIC SUB GridView_Resize()
  
  HideEditor
  
END


PUBLIC SUB GridView_Hide()
  
  HideEditor
  
END


PUBLIC SUB GridView_Change()
  
  HideEditor
  
END


PUBLIC SUB Edit(OPTIONAL List AS String[], OPTIONAL ReadOnly AS Boolean)

  'DEBUG  
  HideEditor
  
  $iCol = ME.Column
  $iRow = ME.Row
  
  IF $iCol < 0 OR $iRow <0> 0
        DEC ME.Row
        RAISE Click
        IF $hEditor THEN
          STOP EVENT
          BREAK
        ENDIF
      WEND

    CASE Key.Down
      WHILE ME.Row <ME> 0 THEN RETURN 

      DO
        IF ME.Column > 0 THEN 
          DEC ME.Column
          RAISE Click
        ELSE IF ME.Row > 0 THEN
          ME.MoveTo(ME.Row - 1, ME.Columns.Count - 1) 
          RAISE Click
        ELSE
          BREAK
        ENDIF
        IF $hEditor THEN
          TRY $hEditor.Pos = $hEditor.Length
          STOP EVENT
          BREAK
        ENDIF
      LOOP

    CASE Key.Right
      IF $bTextBox AND IF $hEditor.Pos < $hEditor.Length THEN RETURN

      DO
        IF ME.Column < (ME.Columns.Count - 1) THEN 
          INC ME.Column
          RAISE Click
        ELSE IF ME.Row < (ME.Rows.Count - 1) THEN
          ME.MoveTo(ME.Row + 1, 0)
          RAISE Click
        ELSE
          BREAK
        ENDIF
        IF $hEditor THEN
          TRY $hEditor.Pos = 0
          STOP EVENT
          BREAK
        ENDIF
      LOOP
      
    CASE Key.Enter, Key.Return
      IF $bTextBox THEN 
        DO
          IF ME.Column < (ME.Columns.Count - 1) THEN 
            INC ME.Column
            RAISE Click
          ELSE IF ME.Row < (ME.Rows.Count - 1) THEN
            ME.MoveTo(ME.Row + 1, 0)
            RAISE Click
          ELSE 
            RAISE Insert
            STOP EVENT
            BREAK
          ENDIF
          IF $hEditor THEN
            TRY $hEditor.Pos = 0
            STOP EVENT
            BREAK
          ENDIF
        LOOP
      ENDIF

  END SELECT 
  
END
[/code]


