re-usable tabControl

dlvonde

Active member
Joined
Oct 26, 2007
Messages
26
Programming Experience
1-3
Good Afternoon,

I am working on my Senior project and we have decided to create a utility to monitor servers on a network from a single location. We decided to use VB.Net because it is somewhat simple to pull up CPU, Hard Drive, Memory, Network, etc. information using the System.Diagnostics.PerformanceCounter objects.

We are able to retrieve the information we need but unfortunately our program isn't very re-usable right now.

The interface should consist of a tabControl for each server. This tabcontrol contains an overview tab, then several other tabs with more in-depth information about each aspect of the computer CPU, Memory...etc.

I am trying to take this tabControl and all of it's text boxes, progress bars, labels, etc. and turn it into a single object that I can create as many instances of as needed. The only argument needed for each new object is a string argument which would be the name of the computer I am trying to get information about (it would be used in the .MachineName attribute of the PerformanceCounter object).

I looked around here and found someone mentioning to use a user defined control. I created that but it looks like an entire project and I don't know how to import it as a single neat control into my new project.

So to sum it all up I need to make a class that has all of the controls, etc. that I will need so that on my main form load I can say for each IP address/computer name/etc. create a new instance of this class and feed it the machinename as a string argument. The controls should then begin populating the main form until all of the computer names have been read.

any help would be greatly appreciated!
 
A Usercontrol is like a form, you design it visually like form and add code to it, but in the end it is a single control. When you create a UserControl in project it also adds to Toolbox (under "WindowsApplication1 components" tab), but you can also create and add it in code like Label (dim l as new label, dim u as new usercontrol1)
 
ok I'll look again..I created a new user control but it never showed up in my toolbox...I can manually create a new instance of the object i created but it doesn't show on the form..I even tried the .Show() and the .Visible=True but it still doesn't appear on my form.

The next logical issue is how to dynamically create as many of these controls as needed..for instance, for each server I have in a list of servers I have to be able to dynamically create that many controls and have them each laid out neatly in my main form...

any pointers for that would be most helpful as well!

thanks again
 
Last edited:
You can add them to a FlowLayoutPanel.
VB.NET:
for i as integer = 1 to 10
  dim u as new usercontrol1
  u.property = "value"
  FlowLayoutPanel1.controls.add(u)
next
 
thanks again! I'll add that once I get over this other hump :).

what is this "property" you are referencing? I finally got my user control to show up by building in design mode but when I create an instance of it the "property" attribute is not available.
 
Last edited:
hello,

I'm making good progress but the thing about creating new usercontrols presents a problem..I need to create multiple new instances of my usercontrol but they can't all be named "u"...but I don't know how to dynamically create new object names?

thanks
dlv
 
'u' is only a variable name, it is only a reference to the object instance, nothing more. If you want to set names to the controls you can set the Name property.
VB.NET:
u.Name = "usercontrol1" & i.ToString()
 
john..that was quick..i actually wrote the question..went back and figured it out and felt quite silly..:p.

I'm just going to use an incrementing integer and after creating each object set u.name = "Server" & i.toString()

thanks again for your quick help!
 
Back
Top