Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > listbox on ado.net
 

listbox on ado.net

My form works fine except for one thing. I have a listbox of customers and when selected, data about each one is displayed in a dgv. The problem is that no other controls on the form work. If I use the navigation arrows to scroll through the records everything works fine. I think my listbox is cuasing a focus/unfocus problem but i'm not sure. Can anyone help?

flatarheel  Friday, August 14, 2009 10:39 PM
I should have moved this to the Ado.net area instead of windows forms. Please redirect this post to that area.

Thanks
Chris Robinson
Program Manager -DataSet
This posting is provided "AS IS" with no warranties, and confers no rights.
Chris Robinson- MSFT  Monday, August 17, 2009 4:25 PM

Hi flatarheel,

You said The problem is that no other controls on the form work. Could you please tell me what issues you met on other controls?

You also said I think my listbox is cuasing a focus/unfocus problem but i'm not sure.
You can handle GotFocus or LostFocus events and show some messages to trace the focus changing in the form. This is a code snippet:
private void Form1_Load(object sender, EventArgs e)

{

foreach (Control ctrl in this.Controls)

{

ctrl.GotFocus += new EventHandler(ctrl_GotFocus);

ctrl.LostFocus += new EventHandler(ctrl_LostFocus);

}

}

void ctrl_GotFocus(object sender, EventArgs e)

{

Console.WriteLine((sender as Control).Name + "got focus.");

}

void ctrl_LostFocus(object sender, EventArgs e)

{

Console.WriteLine((sender as Control).Name + "lost focus.");

}

It is appreciated if you could provide a code snippet or provide more information about the issue.

Let me know if this helps.
Aland Li


Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Tuesday, August 18, 2009 8:55 AM
Hi flatarheel,

Could you please tell me if my reply helps or the issue is already solved?

Regards,
Aland Li

Please mark the replies as answers if they help and unmark if they don't. This can be beneficial to other community members reading the thread.
Aland Li  Friday, August 21, 2009 3:28 AM
I suspect it is a databinding issue. Could you please post the code you use to databind your listbox and your datagridview?
~~Bonnie Berent [C# MVP]
BonnieB  Sunday, August 23, 2009 4:42 AM

You can use google to search for other answers

Custom Search

More Threads

• Databinding ComboxBox, combo is bounded but behaves like no items present??????
• Simple DataBinding Question
• BindingSource Filter max lenght and stack overflow
• DataGridView celll into DataGridViewComboBoxCell
• Excel automation
• How can make one cells value changed with other cell value same time in DataGridView ?
• how to sort winform's databinding by related table's column?
• Problems with Data Adapter Wizard
• Need Help: Image In A Datagrid Column (code partially from here)?
• ArgumentException from BindingSource when closing a form