I am wanting to create a function that will add a textbox or label to a form, my problem is that I need my user to be able to access all of the properties of that object.
Is there any way to give the calling program access to those properties without having to list every single one of them?
Thanks,
Squirrelly1
Last edited by squirrelly1; Feb 16th, 2005 at 10:44 AM.
Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?
Private Function AddtextBox(ByVal txtTemp As TextBox) As TextBox
txtTemp.Name = "TestText1"
txtTemp.Width = 40
txtTemp.Top = 15
txtTemp.Left = 24
txtTemp.Text = "New text Box"
txtTextBox.Visible = True
Return txtTemp
End Function
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
I may have misunderstood you. If you want the user to have access to the properties, you must list them somewhere. Otherwise, how is the user going to select the property wants to access? If you mean you want to create several TextBoxes/labels and don't want to list all the properties every time in your code, then yes you can.
Perhaps you can elaborate a little.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
The calling event CAN set the parameters and pass them to the function.
The purpose of having a function would be if you wanted to use it from other forms - make it Public and preferably put it in the Module.
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Actually I'm going to put it into a DLL so that I only have to change one file when I want to make changes to the user interface. I doubt I'm the first one who thought of this, but I'm still pretty proud of it. LOL
Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?
I don't know why you originally said "I need my user to be able to access all of the properties of that object" but that is how you can do it. The code you wrote couldn't be done at runtime whereas the property name and value in the reflection example can be passed in as text at anytime. I just wrote the example to show you the basic code of how to use reflection to get or set properties at runtime. Also reflection doesn't care what typeof object you pass it as long as you use correct property names.
So you could script or have the user type in a property name and value at runtime and have it set or retrieved at runtime on any object. There is also the option of the PropertyGrid control which you could use to get/set properties of an object.
I have an example related to Reflection that demonstrates what I mean but it also has other junk and I'm afraid it is not well commented. Let me know if you want me to post it.
Last edited by Edneeis; Feb 17th, 2005 at 01:10 AM.
Here you go. Select a control from the left then the 'Refresh' link on the right. That will fill the treeview with all the properties of the last selected control. Then just pick a property and change it using the set/get links on the bottom right. Some properties can not be sent because I didn't work out how to translate the more complex types from a string.
Actually, I downloaded the file before I posted that I would take a look when I had time, and I happen to be working and unable to devote the attention required to learn from this example right now.
erm... joke?
Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?
Actually, I downloaded the file before I posted that I would take a look when I had time, and I happen to be working and unable to devote the attention required to learn from this example right now.
erm... joke?
I don't think he's being offensive. English is not his native language. I have had one or two misunderstandings with his meanings but he really sounds friendly
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Since your wanting to post screen snapshots... take a look at this one and call me liar... It is not my fault if the system is messed up... it was still showing 0 views when you posted your little comment.
Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?
I think there is a genuine misunderstanding here. Kulrom, you are assuming that the forum clock etc is infalible. It is not as I have noticed occasions when the time goes haywire (i.e. gets confused). I've seen posts timed earlier that the previous post by several hours. Squirrelly1 has no reason to make a false claim on this. It would be better to accept that it is a system fault rather than a personal one.
It's a bit like line calls in tennis. We all call what we believe we see but often see calls differently. It's not that someone is dishonest but the way the human brain and eyes work.
Can we call a let please?
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
Hey not to beat a dead horse or anything but the File Create and Modify dates are the times that I made the zip otherwise it would be before even my post.
Anyway I don't want to get you started again, I just had to throw that in there and definately the forum clock has some issues from time to time.
Teeheehee... Sry guys, I've been at my gf's all weekend. Erm? Maybe I misunderstood you, which is completely likely, but did you say that the created and modified date/time for a file that was downloaded onto my computer is based upon the date/time that you created the zip file on your computer??? I thought that sounded a little funny so I checked it out... here you go...
I promise to leave the damned horse alone now...
Squirrelly1
Now happily married and still crankin' away at the keyboard. Life is grand for a coder, no?