Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Dec 17, 2017 10:56 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Listbox question
PostPosted: Thu Feb 07, 2013 5:03 am 
Offline

Joined: Wed Jan 19, 2011 2:52 am
Posts: 11
Hello everyone,
if possible, I need some advice on the easiest way to get the selected row in a list box, ie there is an easier way than to check with a cycle from 0 to .ListCount the property "Selected"?
thanks!

Sergio


Top
 Profile  
Reply with quote  
 Post subject: Re: Listbox question
PostPosted: Thu Feb 07, 2013 5:30 am 
Offline
User avatar

Joined: Sun Oct 28, 2012 4:54 am
Posts: 264
Location: Herts, UK
ListBox1.Cell(ListBox1.ListIndex,0)

_________________
Real Studio 2012 R2
SysInfo
BackTrack Linux/BackBox Linux/Debian Lenny/Windows 7/Windows 8/OpenWRT/OpenBSD
& Yes it's me in the Avatar


Top
 Profile  
Reply with quote  
 Post subject: Re: Listbox question
PostPosted: Thu Feb 07, 2013 7:50 am 
Offline

Joined: Wed Jan 19, 2011 2:52 am
Posts: 11
Thank you very much!
I should have read more carefully the manual :oops:

Cheers

Sergio


Top
 Profile  
Reply with quote  
 Post subject: Re: Listbox question
PostPosted: Tue Feb 12, 2013 5:32 am 
Offline

Joined: Sat May 19, 2007 6:01 am
Posts: 300
The easiest way:
When you create the list, then set RowTag = ID of the post in the database.

' ## QUESTION
sql = "SELECT intID, strName, strURL, strURLPath, dteCreated FROM [URL] ORDER BY intID"

dim rs as RecordSet = dbDatabase.SQLSelect(sql)

' ## FILL DATA
IF rs <> NIL THEN
while not rs.eof
lstOffline.AddRow(rs.Field("strName"). StringValue + " " + rs.Field("dteCreated"). StringValue )
'lstOffline.AddRow(rs.Field("strName"). StringValue )
lstOffline.RowTag(lstOffline.LastIndex) = rs.Field("intID"). StringValue
rs.MoveNext
wend


Then user the RowTag in the listbox, when selecting a post.
I just leave a lot of code and you can delete. Hope this helps!
IF me.listindex <> -1 THEN

// PUT DATA IN VISUAL, TO EDIT
//txtURL.Text = Str(me.ListIndex +2)

main.intURLID = me.RowTag(me.ListIndex)

' ## GET FROM DATABASE
Dim dbDatabase As REALSQLDatabase
Dim TargetFile As FolderItem
dbDatabase = New REALSQLDatabase
Dim blnResult as boolean

TargetFile = GetFolderItem(main.strDatabasePath)
dbDatabase.DatabaseFile = TargetFile

blnResult = dbDatabase.Connect
IF dbDatabase.Error THEN
MsgBox dbDatabase.ErrorMessage
END IF
IF blnResult = TRUE THEN
' ## READ FROM DB
dim dr as new DatabaseRecord
dim sql as string

' ## QUESTION
'sql = "SELECT intID, strName, dteCreatedDate, dteCreatedTime, strSearchString FROM [KATLog] WHERE intID = " + str(me.RowTag(me.ListIndex))
sql = "SELECT intID, strName, strURL, strURLPath, strNotes, dteCreated FROM [URL] WHERE intID = " + str( intURLID)
dim rs as RecordSet = dbDatabase.SQLSelect(sql)

//ShowURL(rs.Field("strSearchString"). StringValue)
// SHOW DATA
txtURL.Text = rs.Field("strURLPath"). StringValue
GroupBox1.Caption = rs.Field("strName"). StringValue + " "

if dbDatabase.error then
msgbox str(dbDatabase.ErrorCode) + " -- " + dbDatabase.ErrorMessage
return
end
'lblMonitor.Text = str(intURLID)
'lblMonitor.Text = rs.Field("strSearchString"). StringValue

'' ## CLEAR DATA
''txtURL.text = ""
''btnInsertURL.Caption = "Insert"
''btnInsertURL.Enabled = false
''btnDeleteURL.Enabled = false
'END IF
END IF

dbDatabase.Close

' ## DO VERY FEW THINGS...
btnSave.Enabled = True
btnSave.Refresh
btnEdit.Enabled = True
btnEdit.Refresh
btnDelete.Enabled = True
btnDelete.Refresh

// lblMonitor.text = str(AMM.intURLID)
ELSE
btnSave.Enabled = False
btnSave.Refresh
btnEdit.Enabled = False
btnEdit.Refresh
btnDelete.Enabled = False
btnDelete.Refresh

END IF


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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