|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
control typesive managed to create a procedure to set the the basics on each form but want to expand it to be able to set properties ie colours and text fonts for each type of control on a form ie Public sub setControls( formName as form) dim CtrlControl as Control for each CtrlControl in formName.gettype ' what i want to do is a seclect function by each type select Type case button case TextBox etc end select next end sub can anybody explain how to do this please Peter Newman wrote:
Show quoteHide quote > im trying to write a global function to set controls up throughout a project. Public sub setControls( Ctrls() as Control)> ive managed to create a procedure to set the the basics on each form but > want to expand it to be able to set properties ie colours and text fonts for > each type of control on a form > > ie > > Public sub setControls( formName as form) > dim CtrlControl as Control > for each CtrlControl in formName.gettype > ' what i want to do is a seclect function by each type > select Type > case button > case TextBox > etc > end select > next > end sub > > can anybody explain how to do this please for each Ctrl as Control in Ctrls ' what i want to do is a seclect function by each type select Typeof Ctrl case is Button case is TextBox etc end select next end sub Calling from form: public sub Form_Load(...) me.load setControls(me.controls) end sub That's from memory but it's real close syntax wise. Hi Peter,
What Chris wrote is correct. If you want to set specific properties which are only exist for that control, you need to cast the control to its original class. For example Chris wrote: > Public sub setControls( Ctrls() as Control) ctype(ctrl,button).someProperty = someValue.> for each Ctrl as Control in Ctrls > ' what i want to do is a seclect function by each type > select Typeof Ctrl > case is Button > case is TextBox ctype(ctrl,textbox).someProperty = someValue.Show quoteHide quote > etc > end select > next > end sub > > Calling from form: > public sub Form_Load(...) me.load > setControls(me.controls) > end sub > Hello,
I don't think casting is strictly necessary. If you have the control as type object then you can change any property in it, and if that property exists for the control it would work fine. Of course casting would help you with intellisense. Regards Cyril Gupta You are right. If the array of type object there is no need for
casting. Cyril Gupta wrote: Show quoteHide quote > Hello, > > I don't think casting is strictly necessary. If you have the control as type > object then you can change any property in it, and if that property exists > for the control it would work fine. > > Of course casting would help you with intellisense. > > Regards > Cyril Gupta
Error converting FILETIME to DateTime
Read text-segment from binary file line breaks Where is Page.RegisterClientScriptBlock Available? Tabindex is driving me nuts!!! richtextbox selectedtext bold upper .... how to find out Screen coordinates of selected datagridview cells left and top borders actions done twice but only one trigger? creating code on the fly at runtime How to get all files from http server |
|||||||||||||||||||||||