Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

A table with two columns, how to fit the colums in the table?

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-25-2009, 11:10 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default A table with two columns, how to fit the colums in the table?

Hello,
I have a table that has two columns.
When I fill the table, I want that the second column will be resized to stay in the table width.

There are two cases:
  1. The rows are a lot so the table shows a vertical scrollbar
  2. The rows are few so I don't need the scrollbar
How can I manage this?
I've tried to do this:
Code:
<div align="left"><font face="Verdana"><font size="2"><font color="#010101"><font color="#010101"><font face="Times New Roman">Table1.ColWidth("Col1")  = 100
</font></font></font></font></font><font face=
"Verdana"><font size="2"><font color="#010101"><font color="#010101"><font face="Times New Roman">Table1.ColWidth("Col2")  = Table1.Width - </font></font></font></font></font><font face="Verdana"><font size="2"><font color="#010101"><font color="#010101"><font face="Times New Roman">Table1.ColWidth("Col1")</font></font></font></font></font></div>
but of course this is not the correct way to accomplish this.

I've read this in the forum, but I'm not sure if this will be a solution for me.

Someone can help me, please?
Reply With Quote
  #2 (permalink)  
Old 07-26-2009, 02:17 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

You can use the Door library to find the vertical scroll bar and horizontal scroll bar status.
obj1 and obj2 are Objects from the Door library:
Code:
Sub GetScrollBarsProperties (tableName)
    obj1.FromControl(tableName)
    obj1.Value = obj1.GetProperty(
"Controls")
    obj2.Value = obj1.GetProperty2(
"Item"0)
    HScrollVisible = obj2.GetProperty(
"Visible"'Horizontal scroll bar visible (true or false)
    HScrollHeight = obj2.GetProperty("Height"'Horizontal scroll height
    obj2.Value = obj1.GetProperty2("Item"1)
    VScrollVisible = obj2.GetProperty(
"Visible"'Vertical scroll bar visible
    VScrollHeight = obj2.GetProperty("Width"'Vertical scroll bar width
End Sub
Reply With Quote
  #3 (permalink)  
Old 07-26-2009, 02:48 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

I've put on Sub Globals of a module
Code:
obj1.New1(False)
obj2.New1(
False)
Then,
I've put
Code:
Sub GetScrollBarsProperties (tableName)
    obj1.FromControl(tableName)
    obj1.Value = obj1.GetProperty(
"Controls")
    obj2.Value = obj1.GetProperty2(
"Item"0)
    HScrollVisible = obj2.GetProperty(
"Visible"'Horizontal scroll bar visible (true or false)
    HScrollHeight = obj2.GetProperty("Height"'Horizontal scroll height
    obj2.Value = obj1.GetProperty2("Item"1)
    VScrollVisible = obj2.GetProperty(
"Visible"'Vertical scroll bar visible
    VScrollHeight = obj2.GetProperty("Width"'Vertical scroll bar width
    Msgbox(HScrollVisible & "." & HScrollHeight & "." & VScrollVisible & "." & VScrollHeight)
End Sub
So, when I call
Code:
GetScrollBarsProperties(tbEditor)
I receive this error:
Code:
An error occurred on sub editor.frmeditor_show

Line number: XXX

GetScrollBarsProperties(tbEditor)
Error description:
Variable: editor.tbeditor was 
not assigned any value.
Continue?
editor is the module name
tbEditor is the table name

What I can do???
Reply With Quote
  #4 (permalink)  
Old 07-26-2009, 02:53 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

All right, all right, I have to pass the table name in double quotes!

Code:
GetScrollBarsProperties("tbEditor")
So all works!

Thank you very much, Erel!
Reply With Quote
  #5 (permalink)  
Old 07-26-2009, 03:15 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

Mmmhh,
I always receive False in Horizontal and Vertical scroll bar visible (True or False)

It's correct???
I have scrollbars!
Reply With Quote
  #6 (permalink)  
Old 07-26-2009, 03:22 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default



I have to pass True in the constructor for Door object, according to documentation:
Quote:
New1
InitializeDataGrid should be set to true if you are using the object with a Table control.
Reply With Quote
  #7 (permalink)  
Old 07-26-2009, 04:26 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

Ok, there a strange "issue"

The table width is 240
The first column width is 192
The second colum width is 48

So: 192 + 48 = 240, but...

I have to subtract 4 to to first or second colums to avoid horizontal scrollbar!

Why 4?

Maybe I have to consider:
  • 1 pixel border from left side of first column
  • 1 pixel border from rigth side of first column
  • 1 pixel border from left side of second column
  • 1 pixel border from rigth side of second column
??
Reply With Quote
  #8 (permalink)  
Old 07-26-2009, 04:51 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Question

I've edited this post to make it clear the problem:

I have a 240 width table,
I want two colums.

I have only the second column width fixed,
the first colums must adapt his width dinamically if vertical scrollbar is visible or not.

I use this code:
Code:
Public Sub FixScrollBars
obj1.FromControl(
"tbEditor")
    obj1.Value = obj1.GetProperty(
"Controls")
    
    obj2.Value = obj1.GetProperty2(
"Item"0)
    
'HScrollVisible = obj2.GetProperty("Visible") 'Horizontal scroll bar visible (True o False)
    'HScrollHeight = obj2.GetProperty("Height") 'Horizontal scroll height
    
    obj2.Value = obj1.GetProperty2(
"Item"1)
    VScrollVisible = obj2.GetProperty(
"Visible"'Vertical scroll bar visible
    VScrollWidth = obj2.GetProperty("Width"'Vertical scroll bar width

    
If VScrollVisible = True Then
        tbEditor.ColWidth(
"Word") = tbEditor.Width - priorityColumnWidth - VScrollWidth
    
Else
        tbEditor.ColWidth(
"Word") = tbEditor.Width - priorityColumnWidth
    
End If
End SUb
To calculate first column width, I do:

table.width - second_column.widht - Vscrollwidth if scrollbar is visible
table.width - second_column.widht if scrollbar is NOT visible

In both cases, I've seen that the first column has ALWAYS 192 as width dimension.
It seems that tbEditor.ColWidth("Word") assignment is not considered!

Info: I call FixScrollBars function from another module (the Main module), after calling the .Show method for the form that contains the table.
I do this because If I call FixScrollBars in the Show method of the form that has the table, I've noticed that the scrollbars are not detected, infact VScrollVisible is always False!

Someone has a solution?

Last edited by ghale : 07-26-2009 at 05:45 PM. Reason: Added more info
Reply With Quote
  #9 (permalink)  
Old 07-26-2009, 06:57 PM
ghale's Avatar
Basic4ppc Veteran
 
Join Date: Dec 2008
Location: Earth, Europe, Italy, Puglia, Lecce
Posts: 219
Default

No idea about this issue?
Reply With Quote
  #10 (permalink)  
Old 07-27-2009, 08:50 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

If you take a screen shot and blow it up you can see that the Width of a table includes the two pixel wide vertical borders at each side so the display area of a Table is four pixels less than Width property. The same is true for the Height.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy row from table to table petrbury Questions (Windows Mobile) 12 06-24-2011 11:54 PM
Updating multiple columns in SQLite mozaharul Questions (Windows Mobile) 4 02-21-2010 01:46 PM
Table Help ftaylor74 Questions (Windows Mobile) 17 08-08-2009 03:30 PM
Retrieve table filter from the filtered table? LineCutter Questions (Windows Mobile) 1 09-08-2008 06:20 AM
use of Table lu_ozzie Questions (Windows Mobile) 1 04-05-2008 07:53 AM


All times are GMT. The time now is 04:41 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0