[Gambas-user] Table View

Eilert eilert-sprachen at ...221...
Tue May 31 12:28:56 CEST 2005


Well it's so simple:

On the Form (wherever your TableView lives) draw a TextBox and make it 
INVISIBLE by default.

Choose the Double-Click event of the TableView and let it make the 
TextBox appear:

TextBox.Visible = True

At the same time, the X, Y, Width and Height of the TextBox should be 
adapted to the values of the cell the user has clicked on. This cell is 
TableView.Current.Blabla

In my example, "Eingabe" is the TextBox, tbd is the TableView.

The more complicated thing is that you have to guard the input of the 
user and send the TextBox all over the TableView. To achieve that, I 
catch the KeyPressed of the TextBox and decide what to do (this one 
isn't complete yet). I include it for your information.


PUBLIC SUB tbd_DblClick()

   IF tbd.Rows.Count = 0 THEN RETURN

   IF NOT TabelleAnzeigen THEN tbd.Column = 1

   baum.Enabled = FALSE

   tbd.Current.EnsureVisible
   Eingabe.X = tbd.X + tbd.Current.X
   Eingabe.Y = tbd.Y + tbd.Current.Y
   Eingabe.Height = tbd.Current.Height
   Eingabe.Width = tbd.Current.Width
   Eingabe.Visible = TRUE
   Eingabe.SetFocus

   IF TabelleAnzeigen THEN
     Eingabe.Text = TabellenZelle(tblDaten[tbd.Row + 2], tbd.Column + 1)
   ELSE
     Eingabe.Text = rechts[tbd.Row]
   END IF

END




PUBLIC SUB Eingabe_KeyPress()
DIM verschoben AS Boolean

   SELECT CASE Key.Code

   CASE key.Esc
     IF message.Question("Es wurden Daten verÀndert.", "Speichern", 
"Verwerfen") = 1 THEN
       message.Info("Noch nicht implementiert")
     END IF
     Eingabe.Visible = FALSE
     tbd.Refresh
     baum.Enabled = TRUE

   CASE key.Tab
     STOP EVENT
     RETURN

   CASE key.Enter, key.Return
     IF TabelleAnzeigen THEN
       IF tbd.Column < tbd.Columns.Count - 1 THEN
         'Wert ÃŒbergeben an das Array
         tbd.Refresh
         INC tbd.Column
         verschoben = TRUE
       ELSE
         IF tbd.Row < tbd.Rows.Count THEN
           'Wert ÃŒbergeben an das Array
           tbd.Refresh
           INC tbd.Row
           tbd.Column = 0
           verschoben = TRUE
         END IF
       END IF
     ELSE
       IF tbd.Row < tbd.Rows.Count THEN
         rechts[tbd.Row] = Eingabe.Text
         tbd.Refresh
         INC tbd.Row
         verschoben = TRUE
       END IF
     END IF

   CASE key.Down
     IF tbd.Row < tbd.Rows.Count THEN
       IF TabelleAnzeigen THEN
         'Wert ÃŒbergeben an das Array
       ELSE
         rechts[tbd.Row] = Eingabe.Text
       END IF
       tbd.Refresh
       INC tbd.Row
       verschoben = TRUE
     END IF

   CASE key.Up
     IF tbd.Row > 0 THEN
       IF TabelleAnzeigen THEN
         'Wert ÃŒbergeben an das Array
       ELSE
         rechts[tbd.Row] = Eingabe.Text
       END IF
       tbd.Refresh
       DEC tbd.Row
       verschoben = TRUE
     END IF

   END SELECT

   IF verschoben THEN

     IF NOT TabelleAnzeigen THEN tbd.Column = 1

     tbd.Current.EnsureVisible
     Eingabe.X = tbd.X + tbd.Current.X
     Eingabe.Y = tbd.Y + tbd.Current.Y
     Eingabe.Height = tbd.Current.Height
     Eingabe.Width = tbd.Current.Width
     Eingabe.SetFocus

     IF TabelleAnzeigen THEN
       Eingabe.Text = TabellenZelle(tblDaten[tbd.Row + 2], tbd.Column + 
1)
     ELSE
       Eingabe.Text = rechts[tbd.Row]
     END IF

   END IF

END




BUDI ARIEF GUSANDI schrieb:
> 
> 
> Hello Eilert,
> 
> 
> Tuesday, May 31, 2005, 1:15:48 PM, anda menulis :
> 
> 
>> Hi,
> 
> 
>> BUDI ARIEF GUSANDI schrieb:
> 
>> > Hi...
> 
>> > 
> 
>> > How can i make table view component editable ? i learn from
> 
>> > gambas database manager code, but hard to understand.
> 
> 
>> Is that possible anyway? As far as I understand from all docs, the 
> 
>> tableview is graphics-only, i. e. you cannot make it editable itself.
> 
>> Instead, you will have to use a TextBox to be shown above the tableview
> 
>> and on the cell you want to edit.
> 
> 
>> This is how I did it in my current project.
> 
> 
>> Rolf
> 
> 
> Rolf, would you mind to send me some piece of your code (simple one)  on 
> how to do that please ?
> 
> 
> -- 
> 
> Best regards,
> 
>  BUDI                            mailto:budi at ...415...
> 
> ------------------------------------------------------- This SF.Net 
> email is sponsored by Yahoo. Introducing Yahoo! Search Developer Network 
> - Create apps using Yahoo! Search APIs Find out how you can build Yahoo! 
> directly into your own Applications - visit 
> http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005 
> _______________________________________________ Gambas-user mailing list 
> Gambas-user at lists.sourceforge.net 
> https://lists.sourceforge.net/lists/listinfo/gambas-user





More information about the User mailing list