[Gambas-user] Tableview problem
Charlie Ogier
charlie at cogier.com
Mon Mar 11 18:45:11 CET 2019
Hi Peter,
Try the code below in a new project: -
*'
--------------------------------------------------------------------------------------------------------------------*
*ComboBox1 As ComboBox**
**TableView1 As TableView**
**
**Public Sub Form_Open()**
**
**With Me**
** .Padding = 5**
** .Arrangement = Arrange.Vertical**
**End With**
**
**ComboBox1 = New ComboBox(Me)**
**
**With ComboBox1**
** .Visible = False**
** .List = ["", "One", "Two", "Three", "Four", "Five"]**
**End With**
**
**TableView1 = New TableView(Me) As "TableView1"**
**
**With TableView1**
** .Expand = True**
** .Columns.Count = 2**
** .Rows.Count = 50**
**End With**
**
**Form_Resize**
**
**End **
**
**Public Sub TableView1_Click()**
**
**TableView1.EditWith(ComboBox1)**
**ComboBox1.Text = ComboBox1.List[1]**
**
**End**
**
**Public Sub TableView1_Save(Row As Integer, Column As Integer, Value As
String)**
**
**TableView1[Row, Column].Text = Value**
**
**End**
**
**Public Sub Form_Resize()**
**
**TableView1.Columns[0].Width = (TableView1.W - (Me.padding * 2)) / 2 **
**
**End**
**'
--------------------------------------------------------------------------------------------------------------------**
**
*Hope it helps.
Charlie*
**
*On 11/03/2019 14:27, Peter Peyotle wrote:
> Hello and good day.
>
> I have the following problem:
>
> I put a combo box (or another control) in a cell of a tableview. The
> ComboBox is set by clicking on the cell.
> I use the following code:
> '
> -----------------------------------------------------------------------------------------------
> 'Gambas class file
>
> Private myCombo As ComboBox
>
> Public Sub form_Open ()
> myCombo = New ComboBox (TableView1.Children [0])
> Object.Attach (TableView1, Me, "tabEvents")
>
> TableView1.Columns.Count = 2
> TableView1.rows.Count = 15
> TableView1.Columns [0] .Width = TableView1.W / 2 - 15
> TableView1.Columns [1] .Width = TableView1.W / 2 - 15
> End
>
> Public Sub showCombo (tabIndex As Integer)
> Dim Xstart, CorrY As Integer
>
> myCombo.w = TableView1 [0, 1] .Width
> myCombo.h = TableView1 [0, 1] .Height
>
> myCombo.Y = TableView1 [tabIndex, 1] .Y
> myCombo.X = TableView1 [tabIndex, 1] .x
> End
>
> Public Sub tabEvents_Click ()
>
> show combo (Last.row)
>
> End
> '
> --------------------------------------------------------------------------------------------------------------------
>
> It works very well too.
> But, if I scroll the view into the area whose cells are first visible
> by scrolling, then the position fails (thus here: myCombo.Y =
> TableView1 [tabIndex, 1] .Y)
>
> Perhaps this can be compensated by a correction factor.
> But I think the tableview should also place in the not (always)
> visible area correctly.
>
> Thanks for the help - I need her :-(.
>
>
>
> Von meinem Sony Xperia™-Smartphone gesendet
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20190311/cc1b8b8d/attachment.html>
More information about the User
mailing list