I am going in circles trying to loop through properties on 3rd party
controls. For example, I have a textbox that has its maximum length located
at MyTextBox.Prope rties.MaxLength - instead of the dotnet textbox which is
MyTextBox.MaxLe ngth. If I loop a built in dotnet control, it finds the
property no problem. But looping through the 3rd party control,
Properties.MaxL ength does not get listed. I was hoping to find how it names
it using reflection, so I could use GetValue and SetValue to dyanmically set
values of controls without knowing their type until runtime. How can I gain
access to loop ALL the properties of a control?
Dim t As Type = ctl.GetType
For Each pp As PropertyInfo In t.GetProperties ()
Console.WriteLi ne("{0} = {1}", pp.Name, pp.GetValue(ctl , Nothing))
Next
Oct 28 '08
10 1873
Hi!
I also use in my apps the dx controls. I do in my loop over all controls a
simple "select case" to difference beetween the differnt controltypes and
then i set the properties.
That works pretty good.
HTH Wolfgang
"Derek Hart" <de********@yah oo.comschrieb im Newsbeitrag
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
More on the right track, but I cannot seem to get to all the properties.
In the dev express controls, on a textboxedit control, in the property
sheet, there is a property called Properties. I expand that and see a
MaxLength property. So the property would be
textbox1.proper ties.MaxLength - cannot seem to loop through and get the
names of all the properties, so I can find how this one is named, and use
it at runtime to set values to it, because I will not know the type of
control until runtime. And I don't want to convert the control because
there are too many controls to do this for. So if the property exists, I
want to do a setvalue on it. Any ideas on how to find all properties?
"James Hahn" <jh***@yahoo.co mwrote in message
news:O3******** ******@TK2MSFTN GP03.phx.gbl...
>This is taken straight from http://msdn.microsoft.com/en-us/libr...pertyinfo.aspx. It's not actually recursive - you have to repeat it for each member type of interest.
I created a picture box with some scroll bars, which is similar (I think) to your custom controls, and sent the output to a multiline text box.
Imports System.Reflecti on Public Class Form1 Dim indent As Integer = 0 Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As System.EventAr gs) Handles Button1.Click Dim t As Type = PictureBox1.Get Type For Each pp As PropertyInfo In t.GetProperties () listproperties (pp) Next End Sub Sub listproperties( ByVal pp As PropertyInfo) Display(indent , pp.Name) indent += 1 For Each mi As MethodInfo In pp.GetAccessors ListAccessors( mi) Next indent -= 1 End Sub Sub ListAccessors(B yVal mi As MethodInfo) Display(indent , mi.Name) End Sub Sub Display(ByVal indent As Int32, ByVal s As String) textBox1.Tex t += New String(" "c, indent * 2) textBox1.Tex t += s & vbCrLf End Sub End Class
"Derek Hart" <de********@yah oo.comwrote in message news:ud******* *******@TK2MSFT NGP04.phx.gbl.. .
>>Do you have a sample of how I would do that from my code below?
"James Hahn" <jh***@yahoo.co mwrote in message news:%2****** *********@TK2MS FTNGP06.phx.gbl ... You should be looping recursively.
"Derek Hart" <de********@yah oo.comwrote in message news:eI***** *********@TK2MS FTNGP03.phx.gbl ... >I am going in circles trying to loop through properties on 3rd party >controls . For example, I have a textbox that has its maximum length >located at MyTextBox.Prope rties.MaxLength - instead of the dotnet >textbox which is MyTextBox.MaxLe ngth. If I loop a built in dotnet >control, it finds the property no problem. But looping through the 3rd >party control, Properties.MaxL ength does not get listed. I was hoping >to find how it names it using reflection, so I could use GetValue and >SetValue to dyanmically set values of controls without knowing their >type until runtime. How can I gain access to loop ALL the properties of >a control? > Dim t As Type = ctl.GetType For Each pp As PropertyInfo In t.GetProperties () Console.WriteLi ne("{0} = {1}", pp.Name, pp.GetValue(ctl , Nothing)) Next > > > > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: trenchmouth |
last post by:
Does anybody know how I can loop through all the properties in a class I
have created? Can I use Me to refer to the properties? I'm using VB6.
Many thanks.
|
by: ALthePal |
last post by:
Hi,
I'm not sure if we are able to or even how to loop through the web forms in
a VB.NET project during design time. In MSAccess we are able to go through
the database -> forms collection and loop through all the forms in a database
and pull information about the form (controls and properties). We would need
to do the same in our VB.NET project; loop through the project and get the
web form's control and property information...
|
by: sparks |
last post by:
I was going to loop thru the tables and change some properties.
10 <<<<<< prp.value --prp.name = Type
False <<<<prp.value --prp.name = allow zero length
10 <<<<<< prp.value --prp.name = Type
True <<<<prp.value --prp.name = allow zero length
10 <<<<<< prp.value --prp.name = Type
True <<<<prp.value --prp.name = allow zero length
10 <<<<<< prp.value --prp.name = Type
True <<<<prp.value --prp.name = allow zero length
4 <<<<<< prp.value...
|
by: Martin |
last post by:
Hi,
Can anybody please tell me (or point me to documentation on) how to loop
through all AD properties of a user.
The code I have so far is below.
Now if I know the property name I can retrieve it, for eample to retrieve
"DisplayName"
I would just say.
de.Properties.Value
|
by: jcrouse |
last post by:
I am trying trying to loop through some label controls and setting some
properties for the labels I'm looping through. Currently I am addressing the
labels one at a time with IF...Then logic, like this:
If lblP1JoyUp.BorderStyle = BorderStyle.FixedSingle Then
lblP1JoyUp.Top = 10
| |
by: James Black |
last post by:
If you go to http://dante.acomp.usf.edu/HomeworkAssistant/index.php you
will see my code.
Type in:
s = a + b and hit tab, and you will see the extra words.
How do I remove these?
Here is a snippet of my code:
var myvalue = targ.value;
|
by: fig000 |
last post by:
HI,
I'm new to generics. I've written a simple class to which I'm
passing a generic list. I'm able to pass the list and even pass the
type of the list so I can use it to traverse it. It's a generic list
of business objects. I'm able to see that the type is the correct one
in the debugger.
However when I try to traverse the list using the type I can't
compile. The same type variable I've verified as being passed
|
by: Derek Hart |
last post by:
I am going in circles trying to loop through properties on 3rd party
controls. For example, I have a textbox that has its maximum length located
at MyTextBox.Properties.MaxLength - instead of the dotnet textbox which is
MyTextBox.MaxLength. If I loop a built in dotnet control, it finds the
property no problem. But looping through the 3rd party control,
Properties.MaxLength does not get listed. I was hoping to find how it names
it using...
|
by: BL3WC |
last post by:
Hi,
I encountered an error "Object not supporting this properties or method" while trying to set a checkbox value to 'True" in a loop. The VBA code I use is as follow:
Set a value to intcount (say set intcount to 2)
ME("FieldName" & intcount).Properties.Value = True
increment intcount by 1 and loop back to set another checkbox value to True base on some conditions.
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |