Activate a TableView cell

Post

Posted
Rating:
#1 (In Topic #753)
Avatar
Guru
cogier is in the usergroup ‘Guru’
Does anybody know if you can, in code, select a TableView cell, open it for editing and select the text in the cell ready for rewriting?

I have tried the MoveTo command, but I can't get it to do anything.

The following code creates a TableView that you can edit but I want to be able to select cell[1,1], in code, ready to edit.

Code (gambas)

  1. TableView1 As TableView
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   BuildForm
  6.  
  7.  
  8. Public Sub BuildForm()
  9.  
  10.   With Me
  11.     .Height = 200
  12.     .Width = 200
  13.     .Padding = 5
  14.     .Arrangement = Arrange.Vertical
  15.     .Center
  16.  
  17.   With TableView1 = New TableView(Me) As "TableView1"
  18.     .Expand = True
  19.     .Rows.Count = 2
  20.     .Columns.Count = 2
  21.     .[0, 0].Text = "Can"
  22.     .[0, 1].Text = "You"
  23.     .[1, 0].Text = "Edit"
  24.     .[1, 1].Text = "me?"
  25.  
  26.  
  27. Public Sub TableView1_Click()
  28.  
  29.   TableView1.Edit
  30.  
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
vuott is in the usergroup ‘Regular’

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’

vuott said

…maybe:

https://www.gambas-it.org/wiki/index.ph … oci_dentro

Thanks vuott but, unfortunately that does not do what I want.

I have worked it out, so here is some code you can try if you are interested.

<IMG src="https://www.cogier.com/gambas/highlight.png"> </IMG>

Code (gambas)

  1. TableView1 As TableView
  2.  
  3. Public Sub Form_Open()
  4.  
  5.   BuildForm
  6.  
  7.  
  8. Public Sub BuildForm()
  9.  
  10.   With Me
  11.     .Height = 200
  12.     .Width = 200
  13.     .Padding = 5
  14.     .Arrangement = Arrange.Vertical
  15.     .Center
  16.  
  17.   With TableView1 = New TableView(Me) As "TableView1"
  18.     .Expand = True
  19.     .Rows.Count = 2
  20.     .Columns.Count = 2
  21.     .[0, 0].Text = "Can"
  22.     .[0, 1].Text = "You"
  23.     .[1, 0].Text = "Edit"
  24.     .[1, 1].Text = "me?"
  25.  
  26.  
  27. Public Sub Form_Activate()
  28.  
  29.   TableView1_Click([0, 1])
  30.  
  31.  
  32. Public Sub TableView1_Click(Optional iRC As Integer[] = [-1, -1])
  33.  
  34.   Dim TextBox1 As Textbox 'Used to hold the TextBox created by the TableView.Edit function
  35.  
  36.   If iRC[0] <> -1 Then TableView1.moveto(iRC[0], iRC[1])
  37.   TableView1.Edit
  38.   TextBox1 = TableView1.Editor
  39.   TextBox1.SelectAll
  40.  
  41.  
Online now: No Back to the top

Post

Posted
Rating:
#4
Regular
vuott is in the usergroup ‘Regular’
it seems to work like this too:

Code (gambas)

  1. ......
  2. ......
  3.  
  4. Public Sub TableView1_Click(Optional iRC As Integer[] = [-1, -1])
  5.  
  6.   Dim TextBox1 As Textbox
  7.  
  8.   If iRC[0] <> -1 Then TableView1.moveto(iRC[0], iRC[1])
  9.   TableView1.Edit
  10.   TextBox1 = TableView1.Editor
  11. ' TextBox1.SelectAll
  12.   TableView1.EditWith(TextBox1)
  13.  
  14.  

Europaeus sum !

<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Online now: No Back to the top

Post

Posted
Rating:
#5
Avatar
Guru
cogier is in the usergroup ‘Guru’
Both methods seem to work well.
Online now: No Back to the top
1 guest and 0 members have just viewed this.