Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu May 24, 2018 8:16 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Inserting tables
PostPosted: Wed Mar 20, 2013 6:11 am 
Offline

Joined: Wed Mar 20, 2013 5:59 am
Posts: 4
Hi folks,

I am an absolute beginner, still using the trial version of Real Studio and have just struggled thru the tutorial.

I now want to create a relatively simple app for the Mac which replicates a puzzle book I wrote some time ago. It requires that I insert two tables in each window. The top table will have 4 columns of different widths. The first two columns will be filled by me and cannot be changed by the user. The last two will require the user to add text.

The other table will contain one word of text in each cell, to be dragged into the empty cells in table 1 (Hope that all makes sense.

Can someone point me in the general direction of creating these tables in the first place. If I can get a little info, I'll try to work out for myself how to proceed.

Thanks in anticipation.

Regards

Batteneye


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting tables
PostPosted: Wed Mar 20, 2013 8:04 am 
Offline

Joined: Mon Aug 14, 2006 9:33 pm
Posts: 1774
First thought is to use a ListBox for this. You can make the 3rd and 4th columns editable (they will be cols. # 2 and #3). The dragging from one LB to another might get a little tricky, but that's definitely where I would start.

_________________
Roger Clary
Class One Software
Educational Software for Lifelong Learning
http://www.classonesoftware.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting tables
PostPosted: Wed Mar 20, 2013 8:22 am 
Offline

Joined: Wed Mar 20, 2013 5:59 am
Posts: 4
Thanks Roger.

I've just taken the first hesitant step in a 1,000 mile journey.

Regards,

Batteneye


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting tables
PostPosted: Thu Mar 21, 2013 7:55 am 
Offline

Joined: Wed Feb 27, 2013 6:40 am
Posts: 6
I would try it this way:

// In the Open-event of the window:

Listbox1.ColumnCount = 4
Listbox1.GridLinesVertical = 2
Listbox1.GridLinesHorizontal = 2
// this is not necessary for dropping text
Listbox1.ColumnType(2) = Listbox.TypeEditable
Listbox1.ColumnType(3) = Listbox.TypeEditable
Listbox1.AcceptTextDrop
Listbox1.EnableDrag = TRUE

Listbox2.EnableDrag = TRUE

// Add rows for both lists
for i as Integer = 1 to 10
Listbox1.AddRow
Listbox2.AddRow "Word " + str(i)
next


// in the DropObject-Event of Listbox1:

dim row, col, i,x as Integer

// which row?
row = obj.DropTop / listbox1.RowHeight

// which column?
for i = 0 to 3
x = x+ me.Column(i).WidthActual
if obj.DropLeft < x then
if i > 1 then
col = i
end if
exit for
end if
next
if col > 1 then
me.Cell(row,col) = obj.Text
end if

// In the DragRow-Event of Listbox2

Drag.Text = Me.List(Row) + EndOfLine //get the text
Me.RemoveRow(Row) // remove the row if you want
Return True //drag


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting tables
PostPosted: Thu Mar 21, 2013 9:35 am 
Offline

Joined: Wed Mar 20, 2013 5:59 am
Posts: 4
Thanks Lavalle,

I've inserted the code as directed and modified the table dimensions to suit my needs. I am now trying to understand the code and what it does.

When I run the project, no issues arise but when I analyse it, I get the message,

"Code, Window1.Listbox1.DropObject Declaration, action is an unused method parameter, Sub DropObject(obj As DragItem, action As Integer)"

I presume this means the code is superfluous.

I'm not sure how to get the 'fixed' text into Cols 1 and 2 of Listbox1 - should I use a label in each cell?
As regards the text which needs to be dragged from the cells in Listbox2 into Cols 3 and 4 of Listbox1, Can you help with that?

(Just so you can picture what I'm up to, in Listbox1 the first column has 20 rows and consecutive Nos. from 1 to 20. Column 2 will have a'cryptic' clue in each row, which must be answered by dragging two words from Listbox2 into columns 3 and 4 of Listbox1.)

Hope all that makes sense.

I really appreciate your help guys.


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting tables
PostPosted: Thu Mar 21, 2013 11:34 am 
Offline

Joined: Wed Feb 27, 2013 6:40 am
Posts: 6
Batteneye wrote:
When I run the project, no issues arise but when I analyse it, I get the message,

"Code, Window1.Listbox1.DropObject Declaration, action is an unused method parameter, Sub DropObject(obj As DragItem, action As Integer)"

I presume this means the code is superfluous.


Yes, ignore it in this case.

Batteneye wrote:
I'm not sure how to get the 'fixed' text into Cols 1 and 2 of Listbox1 - should I use a label in each cell?
As regards the text which needs to be dragged from the cells in Listbox2 into Cols 3 and 4 of Listbox1, Can you help with that?


First of all: RS Documentation is an excellent place for self-studying :)
http://docs.realsoftware.com/index.php/ListBox.AddRow
http://docs.realsoftware.com/index.php/ListBox.Cell


Have a look at the code in the Open-Event:
// Add rows for both lists
for i as Integer = 1 to 20
Listbox1.AddRow
Listbox2.AddRow "Word " + str(i)
next

If you modify it that way:
// Add rows for both lists
for i as Integer = 1 to 20
Listbox1.AddRow str(i) // add numbers (1 to 20) to the first column
Listbox2.AddRow "Word " + str(i) // add the "Words" to the second column
next

you will get the numbers in first column.
The text for the second column you could either add as the second parameter after "str(i)" or with

Listbox1.Cell(1,0) = "Text 1"
Listbox1.Cell(1,1) = "Text 2"
.....
Listbox1.Cell(1,19) = "Text 20"


Top
 Profile  
Reply with quote  
 Post subject: Re: Inserting tables
PostPosted: Thu Mar 21, 2013 1:20 pm 
Offline

Joined: Wed Mar 20, 2013 5:59 am
Posts: 4
Thanks again. You've been very patient and most helpful. I'm 4 days into using the trial version of the RS IDE and getting terribly confused with terms such a Controls, Events, Methods, Classes and Statements.

I'll leave you in peace now and struggle on, hoping it will all make sense one day.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group