We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Class of Windows forms objects

Thread ID:

Created:

Updated:

Platform:

Replies:

3840 Apr 12,2003 11:04 AM Apr 16,2003 11:25 PM Windows Forms 4
loading
Tags: FAQ
Ryan Milligan
Asked On April 12, 2003 11:04 AM

I am trying to create a class of windows forms objects, but I can't seem to get it to work right. I'm fairly new to programming, so I imagine I'm just missing a basic concept. Any help would be appreciated. I want to have a group of objects consisting of a listview, a textbox, 4 buttons, and a label. I then want to be able to run a function within my form code to call this group of objects (called "SearchSection") and specify where to place it on the form.

Ramesh Praveen [Syncfusion]
Replied On April 14, 2003 07:35 AM

Could you please elaborate on "class of windows forms objects"? Did you mean a container control that will host a few windows forms objects? Thanks Praveen

Ryan Milligan
Replied On April 15, 2003 10:54 PM

> Could you please elaborate on "class of windows forms objects"? Did you mean a container control that will host a few windows forms objects? > > Thanks > Praveen > I think that is what I'm looking for. Basically what I need is a Label above a text box which is above 4 buttons lined in a row. Each button would perform a particular function. There would also be a listview that has a few items in it that when selected would change the text of the label to the text of the selected item. This is the group of Windows forms objects that I would like as my "class of windows forms objects". I may be completely off with how I have it set up, but here is what I have tried so far: using System; namespace The_Omega_Tool { public class SearchSection { public System.Windows.Forms.Label SearchesTitle; public System.Windows.Forms.TextBox Input; public System.Windows.Forms.Button Submit; public System.Windows.Forms.Button Copy; public System.Windows.Forms.Button Paste; public System.Windows.Forms.Button Type; public System.Windows.Forms.ListView SearchesList; private System.Windows.Forms.ListViewItem listViewItem1; public int left; public int top; public SearchSection() { placeStuff(this.left, this.top); } public void placeStuff(int x,int y) { this.SearchesTitle = new System.Windows.Forms.Label(); this.Input = new System.Windows.Forms.TextBox(); this.Submit = new System.Windows.Forms.Button(); this.Copy = new System.Windows.Forms.Button(); this.Paste = new System.Windows.Forms.Button(); this.Type = new System.Windows.Forms.Button(); this.SearchesList = new System.Windows.Forms.ListView(); // Search Title. this.SearchesTitle.Text = "Skippy (User ID/Email)"; this.SearchesTitle.Location = new System.Drawing.Point(x,y); //Input box this.Input.Location = new System.Drawing.Point(x, y+16); this.Input.Size = new System.Drawing.Size(128, 20); this.Input.Click += new System.EventHandler(this.Input_Click); // Submit Button this.Submit.Location = new System.Drawing.Point(x+2,y+36); //Copy Button this.Copy.Location = new System.Drawing.Point(x+36,y+36); //Paste button this.Paste.Location = new System.Drawing.Point(x+72,y+36); //Type button this.Type.Location = new System.Drawing.Point(x+108,y+36); //Search list box this.SearchesList.Location = new System.Drawing.Point(x,y); this.SearchesList.Size = new System.Drawing.Size(0,0); } private void Input_Click(object sender, System.EventArgs e) { if(Clipboard.GetDataObject().GetDataPresent(DataFormats.Text)) this.Input.Text = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString(); } } }

Ramesh Praveen [Syncfusion]
Replied On April 16, 2003 03:32 PM

I think you should create a custom UserControl in teh designer filling it with all those Controls. Then, you could instantiate it and place it in your form just like any other control. Regards, Praveen Ramesh

Ryan Milligan
Replied On April 16, 2003 11:25 PM

Being new to this, I didn't even think about that. It worked great. Thanks. This will open many other doors for me in the future. --Ryan

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;