Page 1 of 1

SelectedIndexChanged strange behaviour

Posted: Tue Aug 17, 2010 4:46 am
by jjc
Hi all,
i am getting stuck to work out a strange feature ,i have 2 ChekedListBox and 1 TextBoxControl: CheckedListBoxControl1 (it's populate by a list of cities) and CheckedListBoxControl3 (it's populate by a list of Excursion Services refering to the cities checked in the CheckedListBoxControl1 ) and TextBoxControl6 should display the item selected by the CheckedListBoxControl3 ;

In the event "SelectedIndexChanged " of the CheckedListBoxControl3 i have this code:

Code: Select all

TextBoxControl6.Text = "";
if (CheckedListBoxControl3.SelectedIndex >= 0)
{
for (int i=0;i<CheckedListBoxControl1.Control.CheckedItems.Count;i++)
{
string vari = CheckedListBoxControl1.Control.CheckedItems[i].ToString();
	Excursion_TBL.First();
		while (!Excursion_TBL.IsEof)
		{
			
for (int j=0; j<CheckedListBoxControl3.Control.CheckedItems.Count; j++)
           {
    string record = CheckedListBoxControl3.Control.CheckedItems[j].ToString();
	if (Excursion_TBL.CityCode == vari && Excursion_TBL.CodeExcursionID == record)
				{    
					TextBoxControl6.Text =Excursion_TBL.EnglishDescription1.ToString();
				}
			}
			Excursion_TBL.Next();
		}

}
}
my purpose is each time i select an item in the CheckedListBoxControl3 the TextBoxControl6 will display a description of that record ;
but there is a strange behaviour i have 12 Items in CheckedListBoxControl3 so if i select ir order ascending (from item 0 to item 12) the TextBoxControl6 can display the record instead if i select from (item 12 to item 0) the TextBoxControl6 caould't display anything.
Why i get this strange behaviour?Can you correct me if i wrong something in the code?

Thanks so much .

Have a good day.

Cheers

SelectedIndexChanged strange behaviour

Posted: Tue Aug 17, 2010 8:21 am
by Alex K.
Hello,

Please send us your .MRT file with database for analysis.

Tahnk you.

SelectedIndexChanged strange behaviour

Posted: Tue Aug 17, 2010 8:55 pm
by jjc
Hi Aleksey,
i sent as your request the MRT file with database .
Thanks for your support.

Have a good day.

Cheers

SelectedIndexChanged strange behaviour

Posted: Wed Aug 18, 2010 4:19 am
by Alex K.
Hello,

Hello,

Use following code in CheckedListBoxControl3 events:

Code: Select all

TextBoxControl6.Text = " ";
bool isChecked = false;
for (int checkInd = 0; checkInd<CheckedListBoxControl3.Control.CheckedItems.Count;checkInd++)
{
	if(CheckedListBoxControl3.Control.CheckedItems[checkInd].ToString() == CheckedListBoxControl3.Control.SelectedItem.ToString())
	{
		isChecked = true;
	}
}

if (isChecked)
{
	for (int i=0;i<CheckedListBoxControl1.Control.CheckedItems.Count;i++)
	{
		string vari = CheckedListBoxControl1.Control.CheckedItems[i].ToString();
		Excursion_TBL.First();

		while (!Excursion_TBL.IsEof)
		{
			string record = CheckedListBoxControl3.Control.SelectedItem.ToString();
			if (Excursion_TBL.CityCode == vari && Excursion_TBL.CodeExcursionID == record)
			{
				TextBoxControl6.Text = Excursion_TBL.EnglishDescription1.ToString();
			}
			Excursion_TBL.Next();
		}
	}
}
Thank you.

SelectedIndexChanged strange behaviour

Posted: Wed Aug 18, 2010 4:43 am
by jjc
Hi Aleksey,
thanks so much the code is right to perform the feature i need.

Thanks so much for your support and fast reply.

Have a happy day.

Cheers

SelectedIndexChanged strange behaviour

Posted: Wed Aug 18, 2010 4:53 am
by Alex K.
Hello,

Let us know if you need any additional help.
Have a happy day too.

Thank you.