PDA

View Full Version : ComboBox Reset



azmanar
12-29-2005, 12:05 PM
Hi,

I need to automatically SELECT a ComboBox to the same data that was retrieved from SQLite in a compiled AM6 Project. After scores of tries it wont work and I am lost.

Scenario.
Step 1: After opening an interface, a ComboBox is populated with 3 choices.
Step 2: After selecting 1 choice, I click submit to save it to SQLite.
Step 3: When I retrieve the interface again, the ComboBox has already selected my previous choice.
Step 4. I can reselect another choice from the same ComboBox and save again.

Here is the code:



-- Clear the combobox object
ComboBox.ResetContent("CB_MemberStatus");

--Populate Contents of Membership Status Box
--Table of items to be added to the combobox object (text and data)
tCB_Member_Status = {}
tCB_Member_Status[1] = {sText = "NOT SET", sData = "Not Set Yet"};
tCB_Member_Status[2] = {sText = "RENEWED", sData = "Renewed"};
tCB_Member_Status[3] = {sText = "NOT RENEWED", sData = "Not Renewed Yet"};

-- Step through each item in the table
for nIndex, tItemInfo in tCB_Member_Status do
ComboBox.AddItem("CB_MemberStatus", tItemInfo.sText, tItemInfo.sData);
if tItemInfo.sData == sMemberStatus then
ComboBox.SetSelected("CB_MemberStatus", nIndex);
end



sMemberStatus is basically a variable containing a data retrieved from SQLite statement, which was earlier saved. I am pretty sure that the data retrieved is similar to the combobox data.

Can anyone help?

Thanks

azmanar
12-29-2005, 12:47 PM
The ADD item to ComboBox works well.

The issue is to get the ComboBox choice be selected when it gets compared to a data from DB.

azmanar
12-29-2005, 01:46 PM
The ADD item to ComboBox works well.

The issue is to get the ComboBox choice be selected when it gets compared to a data from DB.

Hi again.

I have resolved it. Whenever I clicked any selected names on my listbox, the Combox Dropdown adjusts itself to the previous selection made and that was saved previously on SQLite DB.

Here's the code for your reference.


-- reset dropdown for Member Status Dropdown
-- Clear the combobox object (needed for when the page is returned to (2nd+ time it is shown)
ComboBox.ResetContent("CB_MemberStatus");

--Set Contents of Membership Status Box
-- Table of items to be added to the combobox object (specify both text and data)
tCB_Member_Status = {}
tCB_Member_Status[1] = {sText = "NOT SET", sData = "Not Set Yet"};
tCB_Member_Status[2] = {sText = "RENEWED", sData = "Renewed"};
tCB_Member_Status[3] = {sText = "NOT RENEWED", sData = "Not Renewed Yet"};

-- Step through each item in the table
for nIndex, tItemInfo in tCB_Member_Status do
ComboBox.AddItem("CB_MemberStatus", tItemInfo.sText, tItemInfo.sData);
if tCB_Member_Status[nIndex].sData==sMemberStatus then
ComboBox.SetSelected("CB_MemberStatus", nIndex);
end
end