|
-
Jul 26th, 2006, 03:06 AM
#1
Thread Starter
Lively Member
[RESOLVED] [02/03] List of interface items
Hi,
Is it possible to get a list containing all the interface objects that contain data? (textboxes, checkboxes, radiobuttons, etc..)
I'm trying export the current settings in the interface to an xml file, and would like it to be done as dynamicly as possible.
-
Jul 26th, 2006, 03:10 AM
#2
Re: [02/03] List of interface items
You'd have to test the appropriate property of each one yourself, e.g. TextLength, Checked, SelectedIndex, etc. I have posted code in the CodeBank to visit every control on a form or else you could use a recursive method. You would just use If...ElseIf statements and the TypeOf statement to test the type of ech control and then the appropriate property, e.g.
VB Code:
If TypeOf ctl Is TextBox Then
If DirectCast(ctl, TextBox).TextLength > 0 Then
'The TextBox is not empty.
-
Jul 26th, 2006, 03:31 AM
#3
Thread Starter
Lively Member
Re: [02/03] List of interface items
Excellent. 
Thanks.
-
Jul 26th, 2006, 04:38 AM
#4
Thread Starter
Lively Member
Re: [RESOLVED] [02/03] List of interface items
How can I find a control object when I have only its name?
For example, I've got a string containing "txtInput", how can I get a handle the txtInput textfield? 
Is there a better way than to loop through each control object and checking its name attribute?
-
Jul 26th, 2006, 04:45 AM
#5
Re: [RESOLVED] [02/03] List of interface items
You can use the CallByName Runtime function if you like, but that will require that the control is declared Public. The CallByName function uses late binding.
-
Jul 26th, 2006, 05:10 AM
#6
Thread Starter
Lively Member
Re: [RESOLVED] [02/03] List of interface items
This call by name function?
Doesn't seem relevant.
It still needs the pointer to the object itself, no?
-
Jul 26th, 2006, 05:41 AM
#7
Re: [RESOLVED] [02/03] List of interface items
CallByName gets the value of a public field, property or function of an object. The form is an object and the TextBox variable is a field.
VB Code:
Dim tb As TextBox = DirectCast(CallByName(Me, "TextBox1", CallType.Get), TextBox)
-
Jul 26th, 2006, 05:53 AM
#8
Thread Starter
Lively Member
Re: [RESOLVED] [02/03] List of interface items
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|