View Full Version : Filter a listbox by a string
Leopard
02-02-2009, 10:17 AM
how can i filter a list box by string??:huh
tnx:yes
\\
another way is to search a string in listbox and copy to second listbox...
but when i do this only "Item Text" will copy and "Item data" will not copy ...
i use this code
callsearch = function()
ListBox.DeleteItem("ListBox2", -1);
for j = 1, ListBox.GetCount("ListBox1") do
local lcl = ListBox.GetItemText("ListBox1", j)
if (String.Find(lcl, Input.GetText("Input1"), 1, false) ~= -1) then
ListBox.AddItem("ListBox2", j.." = "..lcl, "");
end
end
end
ShadowUK
02-02-2009, 10:35 AM
Didn't really need a new thread, Just post in the old one next time.
callsearch = function()
ListBox.DeleteItem("ListBox2", -1);
for j = 1, ListBox.GetCount("ListBox1") do
local lcl = ListBox.GetItemText("ListBox1", j)
if (String.Find(lcl, Input.GetText("Input1"), 1, false) ~= -1) then
ListBox.AddItem("ListBox2", j.." = "..lcl.." (Data: "..ListBox.GetItemData("ListBox1", j)..")", "");
end
end
end
Leopard
02-02-2009, 12:00 PM
Didn't really need a new thread, Just post in the old one next time.
callsearch = function()
ListBox.DeleteItem("ListBox2", -1);
for j = 1, ListBox.GetCount("ListBox1") do
local lcl = ListBox.GetItemText("ListBox1", j)
if (String.Find(lcl, Input.GetText("Input1"), 1, false) ~= -1) then
ListBox.AddItem("ListBox2", j.." = "..lcl.." (Data: "..ListBox.GetItemData("ListBox1", j)..")", "");
end
end
end
tnx :D
it show itemdata in listbox feild
but i want when i click on a feild in listbox2 open itemdata path...
now i have paste this code in listbox2 script :
-- Get the selected index
index = ListBox.GetSelected("ListBox2");
-- Get the data associated with the selected item
data = ListBox.GetItemData("ListBox2", index[1]);
-- Open the document
File.Open(data, "", SW_SHOWNORMAL);
ty :X
ShadowUK
02-02-2009, 01:03 PM
Your code would have worked, But if the selection failed the table would return nil.
So do something like this.
if (ListBox.GetSelected("ListBox2")) then
File.Open(ListBox.GetItemData("ListBox2", ListBox.GetSelected("ListBox2")[1]));
end
Leopard
02-03-2009, 12:36 PM
Your code would have worked, But if the selection failed the table would return nil.
So do something like this.
if (ListBox.GetSelected("ListBox2")) then
File.Open(ListBox.GetItemData("ListBox2", ListBox.GetSelected("ListBox2")[1]));
end
Ty my dear friend ...
but it didn't work...
if upload my project can u correct it for me??
ShadowUK
02-03-2009, 12:55 PM
Ty my dear friend ...
but it didn't work...
if upload my project can u correct it for me??
Woops, I mean.
if (ListBox.GetSelected("ListBox2")) then
File.Open(ListBox.GetItemData("ListBox2", ListBox.GetSelected("ListBox2")[1])));
end
Leopard
02-03-2009, 01:41 PM
Woops, I mean.
if (ListBox.GetSelected("ListBox2")) then
File.Open(ListBox.GetItemData("ListBox2", ListBox.GetSelected("ListBox2")[1])));
end
tnx again...
there was a " ) " extra on this code and it doesn't work yet:o:o:huh
this is my project ...can u correct it for me?
:X;)
Leopard
02-03-2009, 11:47 PM
Woops, I mean.
if (ListBox.GetSelected("ListBox2")) then
File.Open(ListBox.GetItemData("ListBox2", ListBox.GetSelected("ListBox2")[1])));
end
sorry i forgot to say ...
there was an error on this code...
one " ) " was extra and it doesn't work ... :o:o
ShadowUK
02-04-2009, 09:35 AM
This is what happens when you code for too long without sleep.
rexzooly
02-04-2009, 09:38 AM
This is what happens when you code for too long without sleep.
indeed silly things like that happen when you have no sleep.
Leopard
02-04-2009, 01:33 PM
i don't undrestand...
what's wrong with me??:huh
:D
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.