I have this code:
for (int i = 0; i < this.Controls.C ount; i++)
{
if (this.Controls[i] is ValidationTextB ox)
{
// Change the property of the control here.
}
}
ValidationTextB ox is a control which derives from TextBox. It contain
some custom properties, among them: ValidValueColor .
As you see, I'm trying to change a property of all instances of
ValidationTextB ox in my form. When I tried to do
this.Controls[i].ValidValueColo r, I found out that the property wasn't
available. How can I access the custom properties from the
ValidationTextB ox?
Thanks in advance!
Dan 3 1222
this.Controls[i] <--- returns type Control.. so you try something like
((ValidationTex tBox)this.Contr ols[i]).ValidValueCol or, that will work. To
avoid expection include type of check to ensuer that it is correct tpye.. if
(this.Control[i].GetType() == typeof(Validati onTextBox) )
Vijay
"Dan Soendergaard" <da*****@gmail. comwrote in message
news:11******** **************@ 30g2000cwc.goog legroups.com...
>I have this code:
for (int i = 0; i < this.Controls.C ount; i++)
{
if (this.Controls[i] is ValidationTextB ox)
{
// Change the property of the control here.
}
}
ValidationTextB ox is a control which derives from TextBox. It contain
some custom properties, among them: ValidValueColor .
As you see, I'm trying to change a property of all instances of
ValidationTextB ox in my form. When I tried to do
this.Controls[i].ValidValueColo r, I found out that the property wasn't
available. How can I access the custom properties from the
ValidationTextB ox?
Thanks in advance!
Dan
On Mar 10, 4:33 am, "Dan Soendergaard" <dan1...@gmail. comwrote:
I have this code:
for (int i = 0; i < this.Controls.C ount; i++)
{
if (this.Controls[i] is ValidationTextB ox)
{
// Change the property of the control here.
}
}
ValidationTextB ox is a control which derives from TextBox. It contain
some custom properties, among them: ValidValueColor .
As you see, I'm trying to change a property of all instances of
ValidationTextB ox in my form. When I tried to do
this.Controls[i].ValidValueColo r, I found out that the property wasn't
available. How can I access the custom properties from the
ValidationTextB ox?
Try this:
foreach (Control c in this.Controls)
{
ValidationTextB ox vbox = c as ValidationTextB ox
if (vbox != null)
{
// Change the property of the "vbox" control
here.
}
}
On Mar 10, 9:27 pm, "Bruce Wood" <brucew...@cana da.comwrote:
On Mar 10, 4:33 am, "Dan Soendergaard" <dan1...@gmail. comwrote:
I have this code:
for (int i = 0; i < this.Controls.C ount; i++)
{
if (this.Controls[i] is ValidationTextB ox)
{
// Change the property of the control here.
}
}
ValidationTextB ox is a control which derives from TextBox. It contain
some custom properties, among them: ValidValueColor .
As you see, I'm trying to change a property of all instances of
ValidationTextB ox in my form. When I tried to do
this.Controls[i].ValidValueColo r, I found out that the property wasn't
available. How can I access the custom properties from the
ValidationTextB ox?
Try this:
foreach (Control c in this.Controls)
{
ValidationTextB ox vbox = c as ValidationTextB ox
if (vbox != null)
{
// Change the property of the "vbox" control
here.
}
}
Thanks, worked just fine! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: deko |
last post by:
I'm trying to find a way to set form/control properties programmatically.
In a nut shell:
1. Open a database
2. Open a form in design view
3. Do something like this:
For Each prp In frm.Properties
If prp.Name = rst!PropName Then
prp = rst!ChangeTo
|
by: ColinWard |
last post by:
Hi.
I have a form which has as its recordsource an SQL string. The SQL
String is as follows: SELECT * from CONTACTS where false.
this ensures that there is no data loaded in the form when the form is
opened. After the user selects the contact from an unbound combobox I
want the form to be rebound to its recordsource.
I tried using form.recordsource = "Contacts" in the afterupdate event of
|
by: Gerry Abbott |
last post by:
Hi all,
Im wondering why the following will work
Me.Controls("subnonstorePos").visible = False
while
Me.Controls("subnonstorePos").AllowEdits = False
give me an
'property not support by this object error'
|
by: Tony W |
last post by:
Hi,
I am trying to write a simple application to retrieve data from the
Windows registry and insert it into textboxs on a windows form.
So far I have one namespace containing two classess.
The first class handles the form generation - (this was done using GUI
form designer).
|
by: qwerty |
last post by:
I´m new to ASP.Net. My workmate has some experience with it.
He claimed that in ASP.Net working with frames is much simpler than it
was ASP. I asked explanation but he couldn't give me such. (a button
inside a-tag with attribute target isn't anything new relating ASP.Net,
its same old HTML).
He claimed that you could change another page´s controls´s property´s
value from another frame by using this method:
' Page "Bottom"
| |
by: Firewalker |
last post by:
I am attempting to change the backColor property on the previously
instantiated buttons FROM a listbox_doubleClick event.
I thought it would be something like this:
If Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.White) Then
Me.Controls.Item(iSeatNumber).BackColor.Equals(Color.CornflowerBlue)
'End If
|
by: Sakharam Phapale |
last post by:
Hi All,
How to preserve the old font properties while changing new one?
I posted same question 2 months back, but I had very small time then.
eg. "Shopping for" is a text in RichTextBox and already formatted as
"Shopping" ---Bold
"for" -----Regular
Now I want to underline whole text by preserving old style i.e. Bold and
|
by: Dimsion |
last post by:
Hi,
How do i expose all my forms and it controls to other form in the project?
I want to be able to add a form and some control on it, this then be
available to all other forms.
form1 click event:
'this allow me to change the textbox on form2 from form1
Form2.text=""
'this allow me to add item to form2 from form1
|
by: mike_solomon |
last post by:
I have a button
<input type="submit" name="Delete" value="Delete">
This code can not be changed
I want to use Javascript to change the type
I tried:
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |