473,491 Members | 2,636 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Class Library Help PLz

Hi everyone,

I am trying to learn how to use dynamic controls with/by calling a class
library that contains the properties that will set them. Send/called from
the main form. I am using windows forms, C#. The two codes for the two forms
are as follows:
frmMain.cs<< Calling form
using System;
using System.Drawing;
using System.Collections;
using System.Component.Model;
using System.Windows.Forms;
using System.Data;
using System.IO;

public frmMain()
{
InitializeComponent( );
AddControl(new Button( ), new Point(5,5), new Size(75,75), "ButtonName",
0, "");
}
ButtonTest.cs<<


using System;

namespace Test
{
private void AddControl(Control aControl, Point Location, Size Size, String
strText, int TabIndex, string strName);
{
aControl.Location = Location;
aControl..Size = Size;
aControl.Text = strText;
aControl.TabIndex = TabIndex;
aControl.Name = strName;
this.Controls.Add(aControl);
}
}

Any and all help is appreciated.

MikeY
Nov 17 '05 #1
4 1170
What's the problem?

"MikeY" <mi*******@yaho.com> wrote in message
news:wN*******************@news20.bellglobal.com.. .
Hi everyone,

I am trying to learn how to use dynamic controls with/by calling a class
library that contains the properties that will set them. Send/called from
the main form. I am using windows forms, C#. The two codes for the two
forms are as follows:
frmMain.cs<< Calling form
using System;
using System.Drawing;
using System.Collections;
using System.Component.Model;
using System.Windows.Forms;
using System.Data;
using System.IO;

public frmMain()
{
InitializeComponent( );
AddControl(new Button( ), new Point(5,5), new Size(75,75),
"ButtonName", 0, "");
}
ButtonTest.cs<<


using System;

namespace Test
{
private void AddControl(Control aControl, Point Location, Size Size,
String strText, int TabIndex, string strName);
{
aControl.Location = Location;
aControl..Size = Size;
aControl.Text = strText;
aControl.TabIndex = TabIndex;
aControl.Name = strName;
this.Controls.Add(aControl);
}
}

Any and all help is appreciated.

MikeY

Nov 17 '05 #2
Hi Michael,

The problem lies in that when I separate the AddControl function onto a
separate class (page). I send my properties to this, and when I try to build
I get an error because of the "this.Controls.Add(aControl);" The error is
this: "Test.ButtonTest" does not contain a definition for Controls. Hmmm

Also the AddControl function is actually public, not private. I did a
type-o.

Any and all help is appreciated.

MikeY
"Michael C" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:uZ**************@tk2msftngp13.phx.gbl...
What's the problem?

"MikeY" <mi*******@yaho.com> wrote in message
news:wN*******************@news20.bellglobal.com.. .
Hi everyone,

I am trying to learn how to use dynamic controls with/by calling a class
library that contains the properties that will set them. Send/called from
the main form. I am using windows forms, C#. The two codes for the two
forms are as follows:
frmMain.cs<< Calling form


using System;
using System.Drawing;
using System.Collections;
using System.Component.Model;
using System.Windows.Forms;
using System.Data;
using System.IO;

public frmMain()
{
InitializeComponent( );
AddControl(new Button( ), new Point(5,5), new Size(75,75),
"ButtonName", 0, "");
}
ButtonTest.cs<<


using System;

namespace Test
{
private void AddControl(Control aControl, Point Location, Size Size,
String strText, int TabIndex, string strName);
{
aControl.Location = Location;
aControl..Size = Size;
aControl.Text = strText;
aControl.TabIndex = TabIndex;
aControl.Name = strName;
this.Controls.Add(aControl);
}
}

Any and all help is appreciated.

MikeY


Nov 17 '05 #3
"MikeY" <mi*******@yaho.com> wrote in message
news:LC*******************@news20.bellglobal.com.. .
Hi Michael,

The problem lies in that when I separate the AddControl function onto a
separate class (page). I send my properties to this, and when I try to
build I get an error because of the "this.Controls.Add(aControl);" The
error is this: "Test.ButtonTest" does not contain a definition for
Controls. Hmmm

Also the AddControl function is actually public, not private. I did a
type-o.

Any and all help is appreciated.


You have to pass a reference to the page into your function.

Michael
Nov 17 '05 #4
Doh! Sometimes the easiest things are overlooked Thanks Michael much
appreciated your help.

MikeY
"Michael C" <mc*****@NOSPAMoptushome.com.au> wrote in message
news:u9**************@TK2MSFTNGP14.phx.gbl...
"MikeY" <mi*******@yaho.com> wrote in message
news:LC*******************@news20.bellglobal.com.. .
Hi Michael,

The problem lies in that when I separate the AddControl function onto a
separate class (page). I send my properties to this, and when I try to
build I get an error because of the "this.Controls.Add(aControl);" The
error is this: "Test.ButtonTest" does not contain a definition for
Controls. Hmmm

Also the AddControl function is actually public, not private. I did a
type-o.

Any and all help is appreciated.


You have to pass a reference to the page into your function.

Michael

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
1908
by: syd | last post by:
In my project, I've got dozens of similar classes with hundreds of description variables in each. In my illustrative example below, I have a Library class that contains a list of Nation classes. ...
6
6168
by: Patrick | last post by:
Following earlier discussions about invoking a .NET class library via ..NET-COM Interop (using regasm /tlb) at...
4
1746
by: Brian Shannon | last post by:
I am playing around with class libraries trying to understand how they work. I created a class library, library.vb. I placed the library.dll into the bin directory and set my reference. If I...
3
1627
by: eBob.com | last post by:
I have several applications which mine web sites for personal information which they publish. They publish the info in one form, I transform the info into Excel spreadsheets. So all these...
5
1925
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
0
1726
by: tony | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. In this user control we have a class...
5
1980
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
5
8596
by: Rainer Queck | last post by:
Hello NG, Is it possible to share the settings of an application with a class libreary? In my case I have a application and a set of different reports (home made) put into a class library. The...
0
2393
by: drawing in aspnet | last post by:
Question about putting the data layer in a separate class library. I keep reading that the data layer should be separated from the presentation layer and put in its own class library. I am...
4
1381
by: Steve Baer | last post by:
I've already tested this with C# and it works, but I'm being paranoid and I wanted to also check here. Our application has a large class library written in C++/CLI for plug-in projects. The...
0
6974
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7146
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
277
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.