I have fairly large (4700 lines) Windows Forms application that I wrote to coordinate three departments in my manufacturing plant. I have many combo boxes throughout the application and all work perfectly, but I have one combo box who's paint works fine on load, but once you change tabs and come back the combobox is frozen. Please note: this is the order of objects Form1 > TableLayoutPanel > TabControl > TabPage > TableLayoutPanel > ComboBox.
After changing tabs (it is painted with whatever background of the tab i just clicked off of):
The only way to fix this is to close the application and reopen. As long as I stay on the tab the control works perfectly the entire time.
Here is how I load the data for the combo box:
private void LoadFGPN()
{
SqlConnection con = new SqlConnection(Properties.Resources.Tef7_Conn);
SqlDataAdapter da;
DataTable dt = new DataTable();
StringBuilder sql = new StringBuilder();
sql.Append("SELECT DISTINCT(material) FROM [TEF7].[CM].[ALLPartNumbers] WHERE material LIKE '_____7______-6RP' OR material LIKE '_____4______-6RP' OR material LIKE '_________8__-6ML' OR material LIKE '_________[0-7,9]__-6ML'");
da = new SqlDataAdapter(sql.ToString(), con);
da.Fill(dt);
if (cbFGPN.DataSource == null)
{
cbFGPN.DataSource = dt;
}
else
{
cbFGPN.DataSource = null;
cbFGPN.DataSource = dt;
}
cbFGPN.ValueMember = "material";
cbFGPN.DisplayMember = "material";
} //loads finished good combo box on kanban
What I've tried:
* SelectionChangeCommitted event and adding .Refresh() and .Invalidate() / .Update() individually with no success.
* Draw Mode property of the combo box is set to Normal
* winforms tabcontrol
* suspend paint
* force paint event
I'm stumped. Any ideas on how to fix this?
EDIT: Just to be ridiculous I tried the following with no success. The control stays hidden.
if (tcMain.SelectedIndex == 0)
{
cbFGPN.Hide();
LoadPreOrderGridview("eKanban", null, null, null, null, null); //loads preorder gridview
LoadFGPN();
LoadRawPN();
cbFGPN.Show();
tlpMain.Refresh();
tcMain.Refresh();
tpKanban.Refresh();
tlpKanban.Refresh();
pnKanban.Refresh();
cbFGPN.Refresh();
}