Mega Code Archive

 
Categories / VB.Net Tutorial / GUI
 

Use Constrols Tag

imports System imports System.Drawing imports System.Windows.Forms public class Tags : inherits Form   private lbl as Label   public sub New()     Size = new Size(300,200)     lbl = new Label()     lbl.Text = "Label..."     lbl.AutoSize = true     lbl.Parent = me     lbl.Location = new Point(10,10)     dim theEnum as new FontStyle()     dim theStyles as FontStyle() = CType([Enum].GetValues(theEnum.GetType()), FontStyle())     dim i as integer = 1     dim style as FontStyle     for each style in theStyles       dim btn as new Button()       btn.Parent = me       btn.Location = new Point(25,25 * i)       btn.Size = new Size(75,20)       btn.Text = style.ToString()       btn.Tag = style       AddHandler btn.Click, AddressOf btn_Click       i += 1     next   end sub   public shared sub Main()      Application.Run(new Tags())   end sub   private sub btn_Click(ByVal sender as object,ByVal e as EventArgs)     dim btn as Button = CType(sender, Button)     dim fs as FontStyle = CType(btn.Tag, FontStyle)     lbl.Font = new Font(lbl.Font, fs)   end sub end class