[Gambas-user] Tableview problem

Peter Peyotle peterpeyotle at gmx.de
Tue Mar 12 09:26:55 CET 2019


Thank you for your answer. I solved the problem. 
The cells have a continuous internal top component. then top is bigger than the field of vision. 
my control must be placed in the field of view. a cell is (unfortunately) not a container. So I have to insert the control relative to the scroll position. 
this is 
tableview [a, b] .y - tableview.scrollY
that's it :-), juhuuuuu

Von meinem Sony Xperia™-Smartphone gesendet

---- Charlie Ogier schrieb ----

>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 ]----
>
>
>
>----[ 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/20190312/98aa0401/attachment-0001.html>


More information about the User mailing list