Lets say I wanna reference an object like Button1 to Button10 .
I make a loop form 1 to 10 and use a string as name so string = "Button" & X
So unsaon mga bro na if I say string.PerfromClick, katung button with same name will be clicked?
 Mga experts, how do i this? (VB.NET)
 Mga experts, how do i this? (VB.NET)
				Lets say I wanna reference an object like Button1 to Button10 .
I make a loop form 1 to 10 and use a string as name so string = "Button" & X
So unsaon mga bro na if I say string.PerfromClick, katung button with same name will be clicked?
 Re: Mga experts, how do i this? (VB.NET)
 Re: Mga experts, how do i this? (VB.NET)
				use reflections
you cant do string.Onclick stuff.
but you can do something like
Type.InvokeMember(.....)
where type is being initialize from a string type name.
uh, la ko kasabot sa code. can u plz help me. the name of the object is "btnAdd" which is the value of Name . So unsaon nako nigamit invoke na maclick nako ang btnAdd by using the Name string?
 
			
			
Make your buttons into arrays.
You could address it directly with button[x].PerformClick.
Or you could make series of "if" statements.
if buttonstring="button1" then
button1.PerformClick
endif
...
you might want to read this
How to: Hook Up a Delegate Using Reflection
or you can do something like
dim hash as new hastable
hash.add("key1",object1)
hash.add("key2",object2)
...
...
public sub dostuff(s as string, hash as hashtable)
dim c as Button = hash(s)
c.PerformClick()
end sub
Last edited by silent-kill; 05-30-2008 at 09:48 AM.
 
			
			I'll go for an array. Array na lang imong buttons. walay daghang kuti. all you need is the index. that all.
 
			
			 hehehe:! may sender object naman!!!
 hehehe:! may sender object naman!!!
				bro s vb.net meron tinatawag n sender para hindi kna mag create ng code to reflect it to the other button. just used the handle..:o
 
			
			help also....
what is the code for connecting to sql server??
example is that if you made a add button of a form registration for xmple..then it will add to the database...
how is it??
 
			
			just google it
| Similar Threads | 
 |