Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Dec 14, 2018 3:11 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Fixed width ListBox columns
PostPosted: Thu Feb 21, 2013 11:19 am 
Offline

Joined: Sat Dec 24, 2011 5:32 am
Posts: 40
Location: Germany
Hello,
I load data from a SQL-Database into a ListBox. Because I do not know in advance how many columns the ListBox will need to have, I put some code in the open event of the ListBox. The code tells how many columns the listbox (lb) should have and sets the width of the columns to 200 pixels.

Code example for a 10 column ListBox:

lb.ColumnCount = 10
dim i as Integer
for i = 0 to 9
lb.column(i).MinWidthActual = 200
lb.column(i).WidthActual = 200
next


Problem 1: After running then project, the horizontal scrollbar does not appear despite the fact, that the listbox content is much wider then the listbox. „ScrollBarHorizontal“ is checked in the IDE.

Problem 2: The above code behaves diferrently if I check/uncheck „AutoHideScrollbars“ for the listbox in the IDE and run the project. If „AutoHideScrollbars“ is checked, the column widths are not set to 200 pixels when I run the project.

Problem 3: When I resize the window/listbox the columns widths always change. The listbox seems to try to fit all the columns into its current width.
To solve Problem 3, I put some code in the „Resized“ event of the window, to make the column withs again 200 pixels wide:

dim i as Integer
for i = 0 to 9
lb.column(i).WidthActual = 200
next

The code in the „Resized“ event resizes the columns but leads to slow redrawing.

What am I doing wrong? How do you programmaticaly give the columns a fixed (or minimum) width which persists even when the window/listbox is resized? How do I make the horizontal scrollbar appear?

Real Studio 2012 R 2.1, Mac OS X 10.6.8


Top
 Profile  
Reply with quote  
 Post subject: Re: Fixed width ListBox columns
PostPosted: Thu Feb 21, 2013 12:07 pm 
Offline

Joined: Sat Dec 24, 2011 5:32 am
Posts: 40
Location: Germany
I made a small example project for demonstration:

http://cmezes.com/lb_example.zip


Top
 Profile  
Reply with quote  
 Post subject: Re: Fixed width ListBox columns
PostPosted: Thu Feb 21, 2013 12:16 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
try putting LB.INVALIDATECELL(-1,-1) (check the LR for syntax.. .I *THINK* that is correct)

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: Fixed width ListBox columns
PostPosted: Thu Feb 21, 2013 1:52 pm 
Offline

Joined: Sat Dec 24, 2011 5:32 am
Posts: 40
Location: Germany
Hello Dave,
thanks for your reply. I tried the „InvalidateCell“ method but it made no difference.
After some trial and error I stumbled upon the fact, the if I use for example ...
lb.ColumnWidths = "200,200,200,200,200,200,200,200,200,200"

in the open event of the listbox, then everything seems to work correctly.
The solution I found seems to be, to assemble a string (according to the number of columns) that passes the column widths to lb.ColumnWidths.
Here is some example code that seems to solve all 3 problems I described and which I put in the open event of the listbox:


dim i, k as Integer
dim c as String

k = 10 // put any number (<64) here

lb.ColumnCount = k

for i = 0 to (k - 1)
if i < (k - 1) then
c = c + "200,"
else
c = c + "200"
end if
next

lb.ColumnWidths = c


Edit: It would be very interesting to know why the first approch behaves so differently.


Top
 Profile  
Reply with quote  
 Post subject: Re: Fixed width ListBox columns
PostPosted: Thu Feb 21, 2013 8:22 pm 
Offline
User avatar

Joined: Thu Sep 10, 2009 2:50 am
Posts: 418
Location: Santa Cruz, CA, USA
I don't know why MinWidthActual doesn't work but WidthExpression seems to do the job...
Sub Action()

lb.ColumnCount = 10

for i As integer = 0 to lb.ColumnCount - 1
lb.Column(i).WidthExpression = "200"
next

End Sub


Top
 Profile  
Reply with quote  
 Post subject: Re: Fixed width ListBox columns
PostPosted: Fri Feb 22, 2013 4:00 am 
Offline

Joined: Sat Dec 24, 2011 5:32 am
Posts: 40
Location: Germany
Thanks,
lb.WidthExpression works as expected.
The „...Actual“ properties do work too, but apparently only afterwards, when the column widths were initially set in the open event of the listbox with „lb.ColumnWidths“ or „lb.WidthExpression“.
Maybe the Language Reference should be more clear how to use this properties.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group