473,383 Members | 1,795 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,383 software developers and data experts.

Passing Control name property

Hello guys,

I'm stuck at the following situation, please advise.

In my app there exists several control buttons (radio and push).
One of the methods is the following:

private void ManageControl (string ButtonName)
{
switch (ButtonName)
{
case "Button1"
{
Button1.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
case "Button2"
{
Button2.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
....
}

The case content is all the same except for the part of the Control
object (Button1, Button2, ...etc.); therefore I want to shrink it to
just one case parameterized with the appropriate button control name
which needs to be managed.
How do I pass these Control Name (: Button1, Button2 etc.) property to
the 'ManageControl' method?
Add parameter out/ref/object/.... ?

Thanks for your time!
greetz, victor

Jan 17 '07 #1
3 1845
Hi

Why not do something like this (i am guessing at your requirements here):

private void ManageControl ( Control c)
{
c.BackColor = Color.FromArgb(nred,ngreen,nblue);
}
Now any control you pass in will have its colour changed., (you may have to
cast to a button type)
"victor" <vi****@somewhere.comwrote in message
news:51********************************@4ax.com...
Hello guys,

I'm stuck at the following situation, please advise.

In my app there exists several control buttons (radio and push).
One of the methods is the following:

private void ManageControl (string ButtonName)
{
switch (ButtonName)
{
case "Button1"
{
Button1.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
case "Button2"
{
Button2.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
....
}

The case content is all the same except for the part of the Control
object (Button1, Button2, ...etc.); therefore I want to shrink it to
just one case parameterized with the appropriate button control name
which needs to be managed.
How do I pass these Control Name (: Button1, Button2 etc.) property to
the 'ManageControl' method?
Add parameter out/ref/object/.... ?

Thanks for your time!
greetz, victor

Jan 17 '07 #2
Daniel,
You're absolutely right!
I was somehow having a blackout and seeking a too difficult solution.
I'll rearrange my code and use your advise.
THANKS A LOT!
;-) victor

On Wed, 17 Jan 2007 11:27:55 -0000, "Daniel"
<Da*****@vestryonline.comwrote:
>Hi

Why not do something like this (i am guessing at your requirements here):

private void ManageControl ( Control c)
{
c.BackColor = Color.FromArgb(nred,ngreen,nblue);
}
Now any control you pass in will have its colour changed., (you may have to
cast to a button type)
"victor" <vi****@somewhere.comwrote in message
news:51********************************@4ax.com.. .
>Hello guys,

I'm stuck at the following situation, please advise.

In my app there exists several control buttons (radio and push).
One of the methods is the following:

private void ManageControl (string ButtonName)
{
switch (ButtonName)
{
case "Button1"
{
Button1.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
case "Button2"
{
Button2.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
....
}

The case content is all the same except for the part of the Control
object (Button1, Button2, ...etc.); therefore I want to shrink it to
just one case parameterized with the appropriate button control name
which needs to be managed.
How do I pass these Control Name (: Button1, Button2 etc.) property to
the 'ManageControl' method?
Add parameter out/ref/object/.... ?

Thanks for your time!
greetz, victor
Jan 17 '07 #3
No probs i have been a victim of that myself in the past. :) Take care.
"victor" <vi****@somewhere.comwrote in message
news:u6********************************@4ax.com...
Daniel,
You're absolutely right!
I was somehow having a blackout and seeking a too difficult solution.
I'll rearrange my code and use your advise.
THANKS A LOT!
;-) victor

On Wed, 17 Jan 2007 11:27:55 -0000, "Daniel"
<Da*****@vestryonline.comwrote:
>>Hi

Why not do something like this (i am guessing at your requirements here):

private void ManageControl ( Control c)
{
c.BackColor = Color.FromArgb(nred,ngreen,nblue);
}
Now any control you pass in will have its colour changed., (you may have
to
cast to a button type)
"victor" <vi****@somewhere.comwrote in message
news:51********************************@4ax.com. ..
>>Hello guys,

I'm stuck at the following situation, please advise.

In my app there exists several control buttons (radio and push).
One of the methods is the following:

private void ManageControl (string ButtonName)
{
switch (ButtonName)
{
case "Button1"
{
Button1.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
case "Button2"
{
Button2.BackColor=Color.FromArgb(nred,ngreen,nblue );
....
}
....
}

The case content is all the same except for the part of the Control
object (Button1, Button2, ...etc.); therefore I want to shrink it to
just one case parameterized with the appropriate button control name
which needs to be managed.
How do I pass these Control Name (: Button1, Button2 etc.) property to
the 'ManageControl' method?
Add parameter out/ref/object/.... ?

Thanks for your time!
greetz, victor

Jan 17 '07 #4

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

Similar topics

2
by: Chaduke | last post by:
I wrote a simple client/server chat program and the client runs as an activex control within an asp page. I have the users logging into the page using widows authentication and I'm using...
2
by: Curtis Justus | last post by:
Hi, I currently have a control that is on a form and I want to pass that exact instance of the control to another form (a child form that appears on a button click). The control has state,...
6
by: Newbie | last post by:
How do I pass string values from one webform to another?
2
by: Akira | last post by:
Hello. I'm having problem with passing parameters from .aspx file to user control. Could anyone tell me how to pass parameters from .aspx file to user control(.ascx) and how to recieve parameters...
0
by: Neelima Godugu | last post by:
Hi All, I have developed a windows forms user control, which I am going to host in Internet Explorer.. I am familiar with the security settings requirement inorder to do the above. I have...
3
by: Dan Nash | last post by:
Hi I'm new to C#, moving from ASP, and slightly confused so bear with me! Basically I've got 4 pages, each of which runs the same user control (some header information). I want to be able to...
3
by: voro.cibus | last post by:
I have been reading up on this all day, and I can't find the answer (or more likely, don't understand the answers I have found) to my problem. I have a table that stores the name of my ascx page....
1
by: paul | last post by:
I have a user control that uses some javascript to fire a popup which is used for a date picker. The textbox (and the button that fires the popup box) needing to get the date is in a user control...
7
by: Jason | last post by:
Hello I've got a very simple C# app, that has a datagrid, a text box, and a button which when clicked opens a second form... Form2 frm2 = new Form2(); frm2.Show(); When I place a datagrid,...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.