troubleshooting Question

How to initialize the child form?

Avatar of YANKAUSKAS
YANKAUSKASFlag for United States of America asked on
.NET ProgrammingC#
4 Comments1 Solution1283 ViewsLast Modified:
I have a form which is a child form of another form, but when the program start this child form also start, this mean that when the child form doesn't finish initialization, the main form can't start.
I use a list view to display the result from a server on this form. QueueParamsEvent will return the name of the queues, QueueMemberEvent will return the member of the queues. QueueEntryEvent will return the entry of the Queues.
But when the program is started, the two events: QueueMemberEvent and QueueEntryEvent will don't have anything because it haven't initialized yet. I want to initialize it as a null value, still display the list view and don't have anything in it, when we have the value, it will be displayed. But .... please help me!

The source code is below:



namespace MainForm
{
    public partial class FrmQueues : Form
    {
        ResponseEvents re;
        public FrmQueues()
        {
            InitializeComponent();
 
            this.MaximizeBox = false;
            this.MinimizeBox = false;
 
            lvQueues.Columns.Add("Queue");
            lvQueues.Columns.Add("tQueue");
            lvQueues.Columns.Add("ServiceLevel");
 
            lvQueuesMember.Columns.Add("Member");
            lvQueuesMember.Columns.Add("Queues");
            lvQueuesMember.Columns.Add("Location");
 
            lvQueuesEntry.Columns.Add("Entry");
            lvQueuesEntry.Columns.Add("Queues");
            lvQueuesEntry.Columns.Add("Channel");
            lvQueuesEntry.Columns.Add("Positions");
 
 
 
            //this.WindowState = FormWindowState.Maximized;       
            // Display Queues and Member
            try
            {
                re = GlobalVars.manager.Connection.SendEventGeneratingAction(new QueueStatusAction());
            }
            catch (EventTimeoutException e)
            {
            }
            foreach (ManagerEvent e in re.Events)
            {
                if (e is QueueParamsEvent)
                {
                    QueueParamsEvent qe = (QueueParamsEvent)e;
                    //lvQueues.Items.Add("QueueParamsEvent" + "\n\tQueue:\t\t" + qe.Queue + "\n\tServiceLevel:\t" + qe.ServiceLevel);
                    int n = lvQueues.Items.Count;
                    lvQueues.Items.Add("");
                    lvQueues.Items[n].SubItems.Add(qe.Queue.ToString());
                    lvQueues.Items[n].SubItems.Add(qe.ServiceLevel.ToString());
                }
                else if (e is QueueMemberEvent)
                {
                    QueueMemberEvent qme = (QueueMemberEvent)e;
                    //lvQueues.Items.Add("QueueMemberEvent" + "\n\tQueue:\t\t" + qme.Queue + "\n\tLocation:\t" + qme.Location);
                    //int n = lvQueues.Items.Count;
                    //lvQueuesMember.Items.Add("");
                    //lvQueuesMember.Items[n].SubItems.Add(qme.Queue.ToString());
                    //lvQueuesMember.Items[n].SubItems.Add(qme.Location.ToString());
                }
                else if (e is QueueEntryEvent)
                {
                    QueueEntryEvent qee = (QueueEntryEvent)e;
                    //lvQueues.Items.Add("QueueEntryEvent" + "\n\tQueue:\t\t" + qee.Queue + "\n\tChannel:\t" + qee.Channel + "\n\tPosition:\t" + qee.Position);
                    //int n = lvQueues.Items.Count;
                    //lvQueuesEntry.Items.Add("");
                    //lvQueuesEntry.Items[n].SubItems.Add(qee.Queue.ToString());
                    //lvQueuesEntry.Items[n].SubItems.Add(qee.Channel.ToString());
                    //lvQueuesEntry.Items[n].SubItems.Add(qee.Position.ToString());
                }
            }
  
        }
 
    
 
        //
            
 
       
    }
}
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros