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 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
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
"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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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. ...
|
by: Patrick |
last post by:
Following earlier discussions about invoking a .NET class library via
..NET-COM Interop (using regasm /tlb) at...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |
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,...
|
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...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 ...
|
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...
| |