events response time?  
Author Message
ahmed921983





PostPosted: Visual C# Language, events response time? Top

this problem faces me alot which is
some of the events didn't execute the code that it responsible to execute until i put a messagebox in the beggining of the execution block,take this as an example which is a event from a combebox events "SelectedIndexChanged"

private void CB_SelectGroup_SelectedIndexChanged(object sender, EventArgs e)
{
//System.Threading.Thread.Sleep(2000);
MessageBox.Show("kk");// <----------------1
int counter = editDataset.Tables[1].Rows.Count;
for (int i = 0; i < counter; i++)
{
if (editDataset.Tables[1].RowsIdeaMusic.ToString() == CB_SelectGroup.SelectedText && selectedTextInfo[CB_SelectGroup.SelectedIndex, 1] == editDataset.Tables[1].RowsIdea[10].ToString())
{

CB_SelectSensor.Items.Add(editDataset.Tables[1].RowsIdea[2].ToString());
}
}
CB_SelectSensor.Enabled = true;
CHB_GroupSetting.Enabled = false;
CHB_SensorSetting.Enabled = false;
}

1-if this is not enabled the next code will not be executed but if the messagebox is enabled as in this block the code executes successfully.

any help please


Visual C#13  
 
 
SvenC





PostPosted: Visual C# Language, events response time? Top

The error must be somewhere else, that simple cannot be related to a MessageBox.Sho being there or not.

Replace MessageBox.Show with System.Diagnostics.Trace.WriteLine("kk"); and check the output window when you debug your code. Does the kk appear Does your code seem to do what you expect Who fills editDataset Same thread, different thread

--
SvenC


 
 
ahmed921983





PostPosted: Visual C# Language, events response time? Top

i found the bug , it's in the if()line
i should replace CB_SelectGroup.SelectedText with CB_SelectGroup.SelectedItem.ToString()