473,320 Members | 2,052 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,320 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 6783
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.