Ok, I am not sure how to do this as I am trying to teach myself C# and create a program for work at the same time.
I have a List of IP addresss:
It could contain anywhere from 1 to 1500 IP addresses. I can access all the items on this list using this debug code to verify the list is set up right.Code:List<IPAddress> addresses
I have a base FlowPanelLayout container in my Windows Form that is Scrollable up and Down:Code:// Loop through the array and send the contents of the array to debug window. for (int counter = 0; counter < addresses.Count; counter++) { System.Diagnostics.Debug.WriteLine(addresses[counter]); }
I want to create a new FlowLayoutPanel foreach IPAddress in that list.Code:// // flowLayoutPanel1 // this.flowLayoutPanel1.AutoScroll = true; this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowLayoutPanel1.Location = new System.Drawing.Point(12, 67); this.flowLayoutPanel1.Name = "flowLayoutPanel1"; this.flowLayoutPanel1.Size = new System.Drawing.Size(1172, 597); this.flowLayoutPanel1.TabIndex = 1;
From Research it looks like I can use the list as a Dictionary file to create a new variable name for each FlowPanel only I am not sure how.
I did a test FlowPanel and came up with the layout below, I would like each Dynamicly created FlowPanel to be scrollable if needed Left to Right, to have a Label (The IP Address) and 6 buttons for that location each with the same text on them: Router, Switch, Steelhead, InPath, Server, and NCAP.
I would also like to be able to do On Click and On Load Events later for each of these buttons being created. Do I have to do this now when they are being created or would I be able to do a separate void for that later?
Code:// // flowLayoutPanel2 // this.flowLayoutPanel2.Controls.Add(this.label2); this.flowLayoutPanel2.Controls.Add(this.button1); this.flowLayoutPanel2.Controls.Add(this.button2); this.flowLayoutPanel2.Controls.Add(this.button3); this.flowLayoutPanel2.Controls.Add(this.button4); this.flowLayoutPanel2.Controls.Add(this.button5); this.flowLayoutPanel2.Controls.Add(this.button6); this.flowLayoutPanel2.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight; this.flowLayoutPanel2.Location = new System.Drawing.Point(3, 3); this.flowLayoutPanel2.Name = "flowLayoutPanel2"; this.flowLayoutPanel2.Size = new System.Drawing.Size(1071, 57); this.flowLayoutPanel2.TabIndex = 0; // // label2 // this.label2.Anchor = System.Windows.Forms.AnchorStyles.Left; this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(3, 18); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(129, 20); this.label2.TabIndex = 0; this.label2.Text = "199.169.250.126"; // // button1 // this.button1.Location = new System.Drawing.Point(138, 3); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(150, 50); this.button1.TabIndex = 1; this.button1.Text = "Router"; this.button1.UseVisualStyleBackColor = true; // // button2 // this.button2.Location = new System.Drawing.Point(294, 3); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(150, 50); this.button2.TabIndex = 2; this.button2.Text = "Switch"; this.button2.UseVisualStyleBackColor = true; // // button3 // this.button3.Location = new System.Drawing.Point(450, 3); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(150, 50); this.button3.TabIndex = 3; this.button3.Text = "Steelhead"; this.button3.UseVisualStyleBackColor = true; // // button4 // this.button4.Location = new System.Drawing.Point(606, 3); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(150, 50); this.button4.TabIndex = 4; this.button4.Text = "InPath"; this.button4.UseVisualStyleBackColor = true; // // button5 // this.button5.Location = new System.Drawing.Point(762, 3); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(150, 50); this.button5.TabIndex = 5; this.button5.Text = "Server"; this.button5.UseVisualStyleBackColor = true; // // button6 // this.button6.Location = new System.Drawing.Point(918, 3); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(150, 50); this.button6.TabIndex = 6; this.button6.Text = "NCAP"; this.button6.UseVisualStyleBackColor = true;




Reply With Quote
