home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 8,956 of 10,840   
   Steve Gerrard to Maarten   
   Re: usercontrol   
   06 Nov 04 10:42:50   
   
   From: mynamehere@comcast.net   
      
   "Maarten"  wrote in message   
   news:418ce84f$0$4340$ba620e4c@news.skynet.be...   
   | hi all   
   |   
   | why should I use a usercontrol for ?   
   | does it have some advantages?   
   |   
   | thanks Maarten   
   |   
      
   A good way to start is to make a user control that contains one regular   
   control, so you can define some special behavior for it. Try this in a   
   new project:   
      
   1. Click on Project menu, Add User Control   
   2. On the user control, place one text box.   
   3. Add the code below. Close the user control window.   
   4. On Form1, place 2 or 3 of your new controls. Your control will appear   
   last on the toolbox, and you can place them just like other controls.   
   5. Run the program, and type stuff in the text boxes.   
   6. Note that you can now use this control as many times as you like on   
   different forms, without having to duplicate the color change code.   
      
   ' User control code   
      
   Private Sub Text1_Change()   
       If InStr(1, Text1.Text, "red", vbTextCompare) Then   
           Text1.ForeColor = vbRed   
       Else   
           Text1.ForeColor = vbBlack   
       End If   
   End Sub   
      
   Private Sub UserControl_Resize()   
       With UserControl   
           Text1.Move .ScaleLeft, .ScaleTop, .ScaleWidth, .ScaleHeight   
       End With   
   End Sub   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca