Real Software Forums
http://forums.realsoftware.com/

ListBox
http://forums.realsoftware.com/viewtopic.php?f=9&t=47235
Page 1 of 1

Author:  jetpr [ Sat Mar 09, 2013 4:20 pm ]
Post subject:  ListBox

Is any ListBox more faste
The RS listbox is no to fast

Author:  MonkeybreadSoftware [ Sat Mar 09, 2013 4:27 pm ]
Post subject:  Re: ListBox

set visible to false while changing a lot to avoid redraws.

Greetings
Christian

Author:  jetpr [ Sat Mar 09, 2013 7:21 pm ]
Post subject:  Re: ListBox

i am using this code

Dim i, c As Integer


if RbItems.Value = True Then
for i = 0 to ListBox1.ListCount -1
//for c = 0 to ListBox1.ColumnCount - 1
if InStr(ListBox1.Cell(i,1), TxtSearch.Text) <> 0 then // different from 0
''ListBox1.CellBold(i,1) = true // make the text bold
ListBox1.InvalidateCell(i,1)
ListBox1.ListIndex=i
else
ListBox1.CellBold(i,c) = false
end if
//next
next
Else
for i = 0 to ListBox1.ListCount -1
//for c = 0 to ListBox1.ColumnCount - 1
if InStr(ListBox1.Cell(i,0), TxtSearch.Text) <> 0 then // different from 0
'ListBox1.CellBold(i,0) = true // make the text bold
ListBox1.InvalidateCell(i,1)
ListBox1.ListIndex=i
else
ListBox1.CellBold(i,c) = false
end if
//next
next

end if

for search but is slow

Author:  MonkeybreadSoftware [ Sun Mar 10, 2013 5:53 am ]
Post subject:  Re: ListBox

you should leave loop with exit command when you are done.
Also I don't think you need to call InvalidateCell explicit.

Greetings
Christian

Author:  DaveS [ Sun Mar 10, 2013 11:10 am ]
Post subject:  Re: ListBox

see here http://forums.realsoftware.com/viewtopic.php?f=1&t=47239

Author:  jetpr [ Sun Mar 10, 2013 12:29 pm ]
Post subject:  Re: ListBox

hi Dave

this no works.

example

if i am looking for ZERO and i have a record with COLA ZERO it never found ZERO
:?:

Author:  jetpr [ Sun Mar 10, 2013 12:36 pm ]
Post subject:  Re: ListBox

Hi Dave i change you code like this and now works perfect
Thanks


Dim search1 As String


if len(TxtSearch.Text)=0 then
listbox1.listindex=-1
else
dim value As String = TxtSearch.Text
Dim I As Integer
dim FoundAt As Integer = -1
FoundAt = -1
for i = 0 to listbox1.ListCount-1
search1=Mid(listbox1.cell(i,0),1,Len(TxtSearch.Text.Trim))
if instr(search1,value) > 0 then
FoundAt = i
exit
end
next
if FoundAt >= 0 then
listbox1.ListIndex = FoundAt
ListBox1.InvalidateCell(i,0)
else
listbox1.listindex=-1
end if
end if

Author:  HMARROQUINC [ Sun Mar 10, 2013 1:58 pm ]
Post subject:  Re: ListBox

Hi,

First of all try to use the insert code tags, makes reading code much easier.

I was looking at your code and noticed a lot of variables being assigned for no good reason. I just typed a bit of code that perhaps could help you.

dim s as string = TextField1.text.trim // Valor a buscar

// Existe algo que buscar y la lista tiene items?
if listbox1.ListCount = 0 then
exit
end if
if s.len = 0 then
listbox1.ListIndex = -1
exit
end if

dim i as integer
for i = 0 to (listbox1.ListCount -1)
if InStr(0, listbox1.Cell(i,0), s) > 0 then
listbox1.ListIndex = i
exit for i // Se encontro lo que se buscaba, ahora hay que salir
end if
next i


Personally I would move the code to a method, I don't like placing code in any action events, what I do is either call a function or a method from the action event, this allows you to call your function from somewhere else in your code if needed.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/