I am currently developing a WCF publish subscribe service for my asp.net publisher and the windows form application subscriber.
For the windows form application, I would be using a flow layout panel to generate the list of panels (of notifications) for my application. When the publisher(asp.net application) publish a post to the service, every subscriber would be able to receive the information and update their panels accordingly. As for my flowlayoutpanel, I have a ComboBox to filter the types of notification, mainly type 1 and 2.
the code for the ComboBox alert is
private void comboAlertType_SelectedIndexChanged(object sender, EventArgs e)
{
flowLayoutForAlert.Dispose();
populateList();
if (comboAlertType.SelectedIndex == 0)
{
flowLayoutForAlert = createFlowLayoutPanel(1);
}
else if (comboAlertType.SelectedIndex == 1)
{
flowLayoutForAlert = createFlowLayoutPanel(2);
}
else
{
flowLayoutForAlert = createFlowLayoutPanel(3);
}
this.Controls.Add(flowLayoutForAlert);
}
the createFlowlayoutpanel(#) is just a method for me to create the panels. The integer inside stands for the type of panels shown, mainly 1 for every single panels, 2 for important ones and 3 for normal ones.
for my PostReceived() callback method for the wcf service, i have the following code
public void PostReceived(String alertId)
{
backgroundForm b = (backgroundForm) Application.OpenForms[0];
b.BeginInvoke((MethodInvoker)delegate()
{
b.getMainFormObject().lblSearch.Text = "lakjslkaja";
b.getSettingsFormObject().player.Play();
b.getMainFormObject().notificationList.Add(new notificationForm("", "", "", "", "", "", 1, 1));
b.getMainFormObject().populateList();
b.getMainFormObject().mainFormLoad();
});
}
the code for the mainFormLoad is
public void mainFormTesting()
{
notificationForm tempForm = (notificationForm)notificationList[0];
tempForm.Show();
flowLayoutForAlert = createFlowLayoutPanel(1);
this.Controls.Add(flowLayoutForAlert);
}
when I first start the application, the combobox alert filter works for the initial amount of panels, but when I publisher a post and the app receives the post, it sort of screws up the combo box filter function.
Can anyone solve this?
Managed to solve it by first disposing the original panels before calling the codes above.