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

Control property dymicaly assignment

Hii all,

Its my first thread on this forum. It seems great for solutions of programming problems.

I have created a Method which will accept the type of control and 4 defined property of control.
This method will create a control on the form and assign these 4 common properties on the control and it will put the created control on the form.

Now I want one more method which will allow user to assign the property which user want to assign
i.e.
Expand|Select|Wrap|Line Numbers
  1. SetProperty("TextBox1","ReadOnly","True")
This method should assign readonly property to textbox1 created on the form.

I think there is some method which allows to assign property dynamically.

Thanks in advance
Oct 25 '08 #1
1 903
tlhintoq
3,525 Expert 2GB
Hii all,

Its my first thread on this forum. It seems great for solutions of programming problems.

I have created a Method which will accept the type of control and 4 defined property of control.
This method will create a control on the form and assign these 4 common properties on the control and it will put the created control on the form.

Now I want one more method which will allow user to assign the property which user want to assign
i.e.
Expand|Select|Wrap|Line Numbers
  1. SetProperty("TextBox1","ReadOnly","True")
This method should assign readonly property to textbox1 created on the form.

I think there is some method which allows to assign property dynamically.

Thanks in advance
You say you have already defined a method with takes control types and properties as its arguments. But in this call you are wanting to send strings for everything. Why the switch? Seems like that is going to make life harder because you have to go searching for control by the name (not type), get the property by name, and parse the third string into a value type as well.

This looks like it will lead down an ugly path filled with nested if statements and lots of switches.

Expand|Select|Wrap|Line Numbers
  1. Control[] FoundControls = Parent.Controls.Find(szPassedControlName, True);
  2. if (FoundControls.Length>0)
  3. {
  4. // Then do a loop here to find the property
  5. // If the property is found then translate the text name of "True" to a boolean value of True
  6. // Assign it
  7. FoundControls[0].ReadOnly = szPassedValueString.ToLower() == "true";
  8. }
Personally, I'd look at ways to send actual controls and properties and values from the calling methods, instead of string representations of them. But that's just me.
Oct 26 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: U-CDK_CHARLES\\Charles | last post by:
List: I'm having trouble attaching an already opened database to a data control. The context here is I'm trying to populate a data combo with a read only snapshot from the DB. However,...
7
by: Frank Millman | last post by:
Hi all I want to control the assignment of a value to an attribute. Instead of allowing it to be changed directly, I want to enforce that a method is called, which will perform the assignment...
2
by: Aaron | last post by:
Hi, I've seen javascript code where a constructor function is passed an argument "document", and inside the function itself the assignment "this.document = document;" is made. This is the code...
9
by: ckerns | last post by:
I want to loop thru an array of controls,(39 of them...defaults = 0). If value is null or non-numeric I want to assign the value of "0". rowString = "L411" //conrol name if (isNaN(eval...
16
by: sneill | last post by:
How is it possible to take the value of a variable (in this case, MODE_CREATE, MODE_UPDATE, etc) and use that as an object property name? In the following example I want 'oIcon' object to have...
0
by: D. Yates | last post by:
Hi All, Say I have two controls Car and Driver. How do get a Car control to reference a Driver control on the properties tab? I'm not interested in changing Driver properties on assignment. ...
6
by: Tom Rowton | last post by:
This one has me a bit confused and I'm not finding what I need in the MSDN or by searching these forums, so here goes... I have a rather large, complex code-in-page WebForm (don't ask) and a...
1
by: Green | last post by:
Hi, I have a question concerning how to manipulate the properties in the user control, and there is an interesting article about this from Microsoft:...
0
by: JJ_377 | last post by:
The following doesn't assign value to the dropdownlist - WHY? ___________________________________________________________________ In a user control (ascx named USACustomer) : Public Property...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
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,...

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.