473,394 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Looking for Dynamic Control Solution

Hi Everyone,

I am working in C#, windows forms.My question is this. All my button dynamic
controls properties are present and accounted for except for the"FlatStyle"
properties. I can't seem to figure out, if there is a way of using
polymorphic way (if that is a word) of doing this particular property. A
sample of my code is as follows:

DynamicControls.ButtonControl(this,btnSearchByName , new Point(5, 75), new
Size(95, 20), "Name",1,""); << Calling

this.btnSearchByName.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
<<<Had to manually input this property here

public static void ButtonControl(Control parent, Control aControl, Point
Location, Size Size, String strText, int TabIndex, string strName)
{
aControl.Location = Location;
aControl.Size = Size;
aControl.TabIndex = TabIndex;
aControl.Text = strText;
aControl.Name = strName;
aControl.Cursor = System.Windows.Forms.Cursors.Hand;
aControl.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
aControl.TabStop = true;
aControl.Enabled = true;
parent.Controls.Add(aControl);
}

What I would like to do is to add this property with in my ButtonControl
function instead of manually adding this below each & every call. Is there a
way of doing this. Also the FlatStyle does not appear in the Intellisense
after "aControl." If there is a way, perhaps someone could provide a quick
simple sample.

Thank you all in advance and have a good weekend.

MikeY
Nov 13 '05 #1
3 6787
Hi GCL

I've wired the event with my first line, control:

DynamicControls.ButtonControl(this,btnSearchByName , new Point(5, 75), new
Size(95, 20), "Name",1,"");

This control/object is being call in/from my frmMain and calls the function
"ButtonControl" with in a seperate .cs called "Dynamic Controls.cs" my
control does all the work of position (5,75), size(95,20) etc. Thank you for
your solution. But, (there always is, lol) your solution is presently what I
am already using, re: (my second line):

this.btnSearchByName.FlatStyle = System.Windows.Forms.FlatStyle.Popup;

This way is working perfectly, but I was looking for more of a polymorphic
way of doing this instead of everytime that I'm writing an control/event I
have to write a "FlatStyle" property after it. I was looking for a way of
adding this to my function "ButtonControl" just like "aControl.Font", but I
can't seem to find the solution myself. hmmm It seems like I'm always coming
up with these querky questions while trying to learn C#, lol. Anyhow, thank
you again GCL. I'll still look for the solution and I'm sure it is one of
those simple things that I've just overlooked.

MikeY

"gcl" <ln*******@comcast.net> wrote in message
news:0a****************************@phx.gbl...
cast it.. For example,

((System.Windows.Forms.Button) (aControl)).FlatStyle =
System.Windows.Forms.FlatStyle.Flat;

Now I got a question for you..
How are you going to wire the events for these dynamic
controls?

Thanks..

-----Original Message-----
Hi Everyone,

I am working in C#, windows forms.My question is this.

All my button dynamic
controls properties are present and accounted for except

for the"FlatStyle"
properties. I can't seem to figure out, if there is a

way of using
polymorphic way (if that is a word) of doing this

particular property. A
sample of my code is as follows:

DynamicControls.ButtonControl(this,btnSearchByNam e, new

Point(5, 75), new
Size(95, 20), "Name",1,""); << Calling

this.btnSearchByName.FlatStyle =

System.Windows.Forms.FlatStyle.Popup;
<<<Had to manually input this property here

public static void ButtonControl(Control parent, Control

aControl, Point
Location, Size Size, String strText, int TabIndex,

string strName)
{
aControl.Location = Location;
aControl.Size = Size;
aControl.TabIndex = TabIndex;
aControl.Text = strText;
aControl.Name = strName;
aControl.Cursor = System.Windows.Forms.Cursors.Hand;
aControl.Font = new System.Drawing.Font("Microsoft Sans

Serif", 8.25F,
System.Drawing.FontStyle.Regular,

System.Drawing.GraphicsUnit.Point,
((System.Byte)(0)));
aControl.TabStop = true;
aControl.Enabled = true;
parent.Controls.Add(aControl);
}

What I would like to do is to add this property with in

my ButtonControl
function instead of manually adding this below each &

every call. Is there a
way of doing this. Also the FlatStyle does not appear in

the Intellisense
after "aControl." If there is a way, perhaps someone

could provide a quick
simple sample.

Thank you all in advance and have a good weekend.

MikeY
.

Nov 15 '05 #2
gcl
Well,

in that function you can check what type of control is
that and check if the control have the FlatStyle
property and if it does, then your
can cast it to button control and set its property

From your message, I still don't see where u wired
to control's events. I was talking about, like for
example,
500 buttons controls, and when the user click
on one of the control, it will trigger the delegate

Anyway, I done them in different way..

Thanks.

-----Original Message-----
Hi GCL

I've wired the event with my first line, control:

DynamicControls.ButtonControl(this,btnSearchByNam e, new Point(5, 75), newSize(95, 20), "Name",1,"");

This control/object is being call in/from my frmMain and calls the function"ButtonControl" with in a seperate .cs called "Dynamic Controls.cs" mycontrol does all the work of position (5,75), size (95,20) etc. Thank you foryour solution. But, (there always is, lol) your solution is presently what Iam already using, re: (my second line):

this.btnSearchByName.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
This way is working perfectly, but I was looking for more of a polymorphicway of doing this instead of everytime that I'm writing an control/event Ihave to write a "FlatStyle" property after it. I was looking for a way ofadding this to my function "ButtonControl" just like "aControl.Font", but Ican't seem to find the solution myself. hmmm It seems like I'm always comingup with these querky questions while trying to learn C#, lol. Anyhow, thankyou again GCL. I'll still look for the solution and I'm sure it is one ofthose simple things that I've just overlooked.

MikeY

"gcl" <ln*******@comcast.net> wrote in message
news:0a****************************@phx.gbl...
cast it.. For example,

((System.Windows.Forms.Button) (aControl)).FlatStyle =
System.Windows.Forms.FlatStyle.Flat;

Now I got a question for you..
How are you going to wire the events for these dynamic
controls?

Thanks..

>-----Original Message-----
>Hi Everyone,
>
>I am working in C#, windows forms.My question is this.

All my button dynamic
>controls properties are present and accounted for
except for the"FlatStyle"
>properties. I can't seem to figure out, if there is a

way of using
>polymorphic way (if that is a word) of doing this

particular property. A
>sample of my code is as follows:
>
>DynamicControls.ButtonControl(this,btnSearchByNam e,
new Point(5, 75), new
>Size(95, 20), "Name",1,""); << Calling
>
>this.btnSearchByName.FlatStyle =

System.Windows.Forms.FlatStyle.Popup;
><<<Had to manually input this property here
>
>public static void ButtonControl(Control parent,
Control aControl, Point
>Location, Size Size, String strText, int TabIndex,

string strName)
>{
>aControl.Location = Location;
>aControl.Size = Size;
>aControl.TabIndex = TabIndex;
>aControl.Text = strText;
>aControl.Name = strName;
>aControl.Cursor = System.Windows.Forms.Cursors.Hand;
>aControl.Font = new System.Drawing.Font("Microsoft
Sans Serif", 8.25F,
>System.Drawing.FontStyle.Regular,

System.Drawing.GraphicsUnit.Point,
>((System.Byte)(0)));
>aControl.TabStop = true;
>aControl.Enabled = true;
>parent.Controls.Add(aControl);
>}
>
>What I would like to do is to add this property with
in my ButtonControl
>function instead of manually adding this below each &

every call. Is there a
>way of doing this. Also the FlatStyle does not appear
in the Intellisense
>after "aControl." If there is a way, perhaps someone

could provide a quick
>simple sample.
>
>Thank you all in advance and have a good weekend.
>
>MikeY
>
>
>.
>

.

Nov 15 '05 #3
Aaaaaaaaah, I've misunderstood you, sorry bro.

I wire the event like this:
btnSearchByName.Click += new System.EventHandler(SearchBoxArea);

You can just treat the "btnSearchByName" just like anyother button, Label,
TextBox, Gridbox etc ie txtBoxFName.text
I do enjoy using Dynamic controls, but sometimes like this & especially
being that I'm still learning the ropes, it can be head scratching, lol.
Anyhow have a great weekend.

Hey if you want a small samply on how I approach this please drop me a line.

MikeY

"gcl" <ln*******@comcast.net> wrote in message
news:04****************************@phx.gbl...
Well,

in that function you can check what type of control is
that and check if the control have the FlatStyle
property and if it does, then your
can cast it to button control and set its property

From your message, I still don't see where u wired
to control's events. I was talking about, like for
example,
500 buttons controls, and when the user click
on one of the control, it will trigger the delegate

Anyway, I done them in different way..

Thanks.

-----Original Message-----
Hi GCL

I've wired the event with my first line, control:

DynamicControls.ButtonControl(this,btnSearchByNam e, new

Point(5, 75), new
Size(95, 20), "Name",1,"");

This control/object is being call in/from my frmMain and

calls the function
"ButtonControl" with in a seperate .cs called "Dynamic

Controls.cs" my
control does all the work of position (5,75), size

(95,20) etc. Thank you for
your solution. But, (there always is, lol) your solution

is presently what I
am already using, re: (my second line):

this.btnSearchByName.FlatStyle =

System.Windows.Forms.FlatStyle.Popup;

This way is working perfectly, but I was looking for

more of a polymorphic
way of doing this instead of everytime that I'm writing

an control/event I
have to write a "FlatStyle" property after it. I was

looking for a way of
adding this to my function "ButtonControl" just

like "aControl.Font", but I
can't seem to find the solution myself. hmmm It seems

like I'm always coming
up with these querky questions while trying to learn C#,

lol. Anyhow, thank
you again GCL. I'll still look for the solution and I'm

sure it is one of
those simple things that I've just overlooked.

MikeY

"gcl" <ln*******@comcast.net> wrote in message
news:0a****************************@phx.gbl...
cast it.. For example,

((System.Windows.Forms.Button) (aControl)).FlatStyle =
System.Windows.Forms.FlatStyle.Flat;

Now I got a question for you..
How are you going to wire the events for these dynamic
controls?

Thanks..


>-----Original Message-----
>Hi Everyone,
>
>I am working in C#, windows forms.My question is this.
All my button dynamic
>controls properties are present and accounted for except for the"FlatStyle"
>properties. I can't seem to figure out, if there is a
way of using
>polymorphic way (if that is a word) of doing this
particular property. A
>sample of my code is as follows:
>
>DynamicControls.ButtonControl(this,btnSearchByNam e, new Point(5, 75), new
>Size(95, 20), "Name",1,""); << Calling
>
>this.btnSearchByName.FlatStyle =
System.Windows.Forms.FlatStyle.Popup;
><<<Had to manually input this property here
>
>public static void ButtonControl(Control parent, Control aControl, Point
>Location, Size Size, String strText, int TabIndex,
string strName)
>{
>aControl.Location = Location;
>aControl.Size = Size;
>aControl.TabIndex = TabIndex;
>aControl.Text = strText;
>aControl.Name = strName;
>aControl.Cursor = System.Windows.Forms.Cursors.Hand;
>aControl.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F,
>System.Drawing.FontStyle.Regular,
System.Drawing.GraphicsUnit.Point,
>((System.Byte)(0)));
>aControl.TabStop = true;
>aControl.Enabled = true;
>parent.Controls.Add(aControl);
>}
>
>What I would like to do is to add this property with in my ButtonControl
>function instead of manually adding this below each &
every call. Is there a
>way of doing this. Also the FlatStyle does not appear in the Intellisense
>after "aControl." If there is a way, perhaps someone
could provide a quick
>simple sample.
>
>Thank you all in advance and have a good weekend.
>
>MikeY
>
>
>.
>

.

Nov 15 '05 #4

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

Similar topics

2
by: charliewest | last post by:
I need to create textboxes in real-time, the actual number of which is determine by a result from a database query. I have been able to create the controls, and then add them to the ASPX page....
3
by: Assaf | last post by:
Hi all. In response to user selections, our app adds controls (buttons, image buttons) dynamically to a page with Controls.Add(myNewButtonControl). Now that we gotten on the page we want to...
5
by: RA | last post by:
I have created a button dynamically; which has been added to a TableCell of a TableRow of a Table control. Is there a way to add onclick event which calls a procedure on the Server-side itself....
2
by: Matt | last post by:
Hi, Can someone provide some information on how to create a control dynamically based on the contents of another dynamic control. In my experience, all dynamic controls must be created in the...
1
by: amirmira | last post by:
I have a multithreaded application is ASP.NET that checks the status of a process every 2 seconds. After the thread has completed, the values of dynamically added controls need to be changed...
2
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a...
1
by: Larry Bud | last post by:
A dynamic control (A dropdown) is created in PageLoad, but the value of the dynamic control dictates where it's added (such as which cell in a table) on a postback. Seems like a catch-22. I...
4
by: brett | last post by:
I load a dynamic control once a button is clicked. In the control is another button. However, I can't get its click event to fire. Here's the pattern: Page1.aspx ---------...
0
by: imranabdulaziz | last post by:
hi all , i am mess with the one situation. i am using asp.net2.0 ,C# and sql server 2005. I have checkboxlist and based on user selection i creates dynamic controls(which code is in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.