| 
Controls in toolbox 
 = 63 + Pointer = 64
 
 
 
 เครื่องมือมากมายที่ไมโครซอฟท์เตรียมไว้ให้ใช้
 | 
' Sample of Control Listing
For Each o As Control In Me.Controls
  MsgBox(o.Name)
Next
TextBox1.Multiline = True
TextBox1.Size = New Size(100, 200)
TextBox1.MaxLength = 50
TextBox2.PasswordChar = "*"c
TextBox1.Text = TextBox2.Text
TextBox1.Text = Len(TextBox2.Text)
TextBox1.Enabled = False
TextBox1.Visible = False
  |   
| 
วินโดว์คอนโทล (Windows Control) ที่น่าสนใจ :
Label ,
Button ,
Textbox ,
RadioButton ,
CheckBox ,
ListBox ,
ComboBox ,
DataGridView ,
MenuStrip ,
ToolStrip ,
TabControl ,
Timer ,
ProgressBar 
 |  
21 Controls
  
 | 
6 Controls
  
 | 
5 Controls
  
 | 
5 Controls
  
14 Controls
  
 | 
5 Controls
  
 | 
5 Controls
  
 | 
2 Controls
  
 |   |   
1  | 
Pointer 
ตัวชี้ตำแหน่ง
 |  2  | 
Button 
Displays a push button control on the Web page.
 |  3  | 
CheckBox 
Displays a check box that allows the user to select a true or false condition.
 |  4  | 
CheckedListBox 
Displays a ListBox in which a check box is displayed to the left of each item.
 |  5  | 
ComboBox 
Represents a Windows combo box control.
 |  6  | 
DateTimePicker 
แสดงข้อมูลวันที่ดอพดาวน์ (Drop Down) และสามารถเลือกวันที่แบบปฏิทินรายเดือนให้คลิ๊กเลือกวันที่
 |  7  | 
Label 
Provides control capability to represent a label control for displaying text on a mobile device. 
 |  8  | 
LinkLabel 
Represents a Windows label control that can display hyperlinks.
 |  9  | 
ListBox 
Represents a list box control that allows single or multiple item selection.
 |  10  | 
ListView 
Represents a Windows list view control, which displays a collection of items that can be displayed using one of four different views.
 |  11  | 
MaskedTextBox 
Uses a mask to distinguish between proper and improper user input.
 |  12  | 
MonthCalendar 
แสดงปฏิทินรายเดือนให้คลิ๊กเลือกวันที่
 |  13  | 
NotifyIcon 
Specifies a component that creates an icon in the notification area. This class cannot be inherited.
 |  14  | 
NumericUpDown 
Represents a Windows spin box (also known as an up-down control) that displays numeric values.
 |  15  | 
PictureBox 
Represents a Windows picture box control for displaying an image.
 |  16  | 
ProgressBar 
Represents a Windows progress bar control.
 |  17  | 
RadioButton 
ปุ่มกลม สำหรับเลือกค่าใดค่าหนึ่งจากหลายค่า
 |  18  | 
RichTextBox 
Represents a Windows rich text box control.
 |  19  | 
TextBox 
กล่องข้อความ ที่รับข้อความตัวอักษรจากผู้ใช้
 |  20  | 
ToolTip 
Represents a small rectangular pop-up window that displays a brief description of a control's purpose when the user rests the pointer on the control.
 |  21  | 
TreeView 
Displays hierarchical data, such as a table of contents, in a tree structure.
 |  22  | 
WebBrowser 
Enables the user to navigate Web pages inside your form.
 |   
 
23  | 
FlowLayoutPanel 
Represents a panel that dynamically lays out its contents horizontally or vertically.
 |  24  | 
GroupBox 
Represents a Windows control that displays a frame around a group of controls with an optional caption.
 |  25  | 
Panel 
Provides a grouping mechanism for organizing controls. 
 |  26  | 
SplitContainer 
Represents a control consisting of a movable bar that divides a container's display area into two resizable panels. 
 |  27  | 
TabControl 
จัดกลุ่มคอนโทลเข้าผ่านแทปคอนโทล เพื่อให้จัดการคอนโทลตามลักษณะงาน
 |  28  | 
TableLayoutPanel 
Represents a panel that dynamically lays out its contents in a grid composed of rows and columns.
 |   
 
29  | 
ContextMenuStrip 
Represents a shortcut menu. 
 |  30  | 
MenuStrip 
Provides a menu system for a form.
 |  31  | 
StatusStrip 
Represents a Windows status bar control. 
 |  32  | 
ToolStrip 
Provides a container for Windows toolbar objects.
 |  33  | 
ToolStripContainer 
Provides panels on each side of the form and a central panel that can hold one or more controls.
 |   
 
34  | 
DataSet 
แหล่งเก็บข้อมูลในหน่วยความจำชั่วคราว (Cache)
 |  35  | 
DataGridView 
Displays data in a customizable grid.
 |  36  | 
BindingSource 
Encapsulates the data source for a form.
 |  37  | 
BindingNavigator 
Represents the navigation and manipulation user interface (UI) for controls on a form that are bound to data.
 |  38  | 
ReportViewer 
Encapsulates the methods and properties used for the ReportViewer control.
 |   
 
39  | 
BackgroundWorker 
Executes an operation on a separate thread.
 |  40  | 
DirectoryEntry 
The DirectoryEntry class encapsulates a node or object in the Active Directory hierarchy.
 |  41  | 
DirectorySearcher 
Performs queries against Active Directory.
 |  42  | 
ErrorProvider 
Provides a user interface for indicating that a control on a form has an error associated with it.
 |  43  | 
EventLog 
Provides interaction with Windows event logs.
 |  44  | 
FileSystemWatcher 
Listens to the file system change notifications and raises events when a directory, or file in a directory, changes.
 |  45  | 
HelpProvider 
Provides pop-up or online Help for controls.
 |  46  | 
ImageList 
Provides methods to manage a collection of Image objects. This class cannot be inherited.
 |  47  | 
MessageQueue 
Provides access to a queue on a Message Queuing server.
 |  48  | 
PerformanceCounter 
Represents a Windows NT performance counter component.
 |  49  | 
Process 
Provides access to local and remote processes and enables you to start and stop local system processes.
 |  50  | 
SerialPort 
Represents a serial port resource.
 |  51  | 
ServiceController 
Represents a Windows service and allows you to connect to a running or stopped service, manipulate it, or get information about it. 
 |  52  | 
Timer 
Provides a mechanism for executing a method at specified intervals. This class cannot be inherited.
 |   
 
53  | 
PageSetupDialog 
Enables users to change page-related print settings, including margins and paper orientation. This class cannot be inherited. 
 |  54  | 
PrintDialog 
Allows users to select a printer and choose which portions of the document to print.
 |  55  | 
PrintDocument 
Defines a reusable object that sends output to a printer.
 |  56  | 
PrintPreviewControl 
Represents the raw preview part of print previewing, without any dialog boxes or buttons. Most PrintPreviewControl objects are found on PrintPreviewDialog objects, but they do not have to be.
 |  57  | 
PrintPreviewDialog 
Represents a dialog box form that contains a PrintPreviewControl.
 |   
 
58  | 
ColorDialog 
เปิดหน้าต่างสำหรับเลือกสี
 |  59  | 
FolderBrowserDialog 
เปิดหน้าต่างสำหรับเลือกโฟรเดอร์ให้แก่ผู้ใช้
 Dim f1 As New FolderBrowserDialog
 f1.ShowDialog()
 TextBox1.Text = f1.SelectedPath
 |  60  | 
FontDialog 
เปิดหน้าต่างสำหรับเลือกแบบตัวอักษรที่ติดตั้งในเครื่องของผู้ใช้
 |  61  | 
OpenFileDialog 
เปิดหน้าต่างสำหรับเลือกแฟ้มให้แก่ผู้ใช้
 OpenFileDialog1.ShowDialog()
 TextBox1.Text = OpenFileDialog1.FileName
 |  62  | 
SaveFileDialog 
เปิดหน้าต่างสำหรับเลือกโฟลเดอร์จัดเก็บแฟ้มของผู้ใช้
 SaveFileDialog1.FileName = TextBox5.Text
 SaveFileDialog1.ShowDialog()
 ' Sub SaveFileDialog1_FileOk ต้องเขียนคำสั่งให้จัดเก็บ เช่น Shell("c:\x.bat", AppWinStyle.NormalFocus)
 |   
 
63  | 
CrystalReportViewer 
This control displays the report in a page-based layout, with the ability to move between pages. 
 |  64  | 
ReportDocument 
ReportDocument class is part of the CrystalDecisions.CrystalReports.Engine namespace. It functions as a gateway to a set of classes in the Engine namespace, which provide more tools for programmatic manipulation of a report.
 |   
 
 
การทำงานกับ MDI Parent Form เพื่อทำ Project
- Add new Item, MDI Parent Form
- Startup form = MDIParent1
Put code in MDIParent1_Load ( )
Private Sub MDIParent1_Load( ..
  Me.WindowState = FormWindowState.Maximized
  Dim f1 = New Form1
  f1.mdiparent = Me
  f1.show()
End Sub
Control object in MdiChildren
Private Sub xxxStripMenuItem_Click( ..
  Dim Fs As Form1
  For Each F As Object In Me.MdiChildren
    If F.Name = "Form1" Then
      Fs = F
      Fs.BackColor = Color.Yellow
      Fs.TextBox1.Text = "hello"
      ' some property is readonly
    End If
  Next
End Sub
 | 
คำสั่ง application.openforms
 28 ม.ค.53 ปกติผมไม่เขียนเรื่องทางเทคนิคใน blog เพราะมีรายละเอียดมาก และเขียนไว้ในเว็บเพจอยู่แล้ว แต่หัวหน้าแนะว่าอยากให้
เขียนเรื่อง application.openforms
ซึ่งเป็นวิธีการส่งค่าระหว่างฟอร์มลูกใน mdiparent ซึ่งผมเคยเขียนไว้ในเว็บเพจว่าใช้วิธีอ้างผ่าน mdiparent 
แต่ทั้ง 2 วิธีที่จะนำเสนอนี้มีความแต่ต่างกันชัดเจน ซึ่งผมจะเขียนเรื่องนี้ไว้ใน
 + http://www.thaiall.com/vbnet/testtoolbox.htm
 ขั้นตอนที่ 1 การสร้างคอนโทล เพื่อเตรียมความพร้อม
สร้าง mdi parent form และ windows form ขึ้น 2 form
เมื่อเปิด solution ให้เรียกทั้ง 2 ฟอร์มมาแสดงใน mdi parent form ทันที
โดยใส่คำสั่งในโหลดของเอ็มดีไอ คือ
dim f1 = new form1 : f1.mdiparent = me : f1.show() : dim f2 = new form2 : f2.mdiparent = me : f2.show()
แล้วในฟอร์มทั้งสองมี ปุ่มและเท็คบ็อกอย่างละหนึ่ง
 ขั้นตอนที่ 2 ทดสอบคำสั่งที่ใช้ส่งค่าเมื่อกดปุ่ม
 กรณีที่ 1  กรอกข้อมูลและสั่งจากฟอร์มหนึ่งแต่มีผลในฟอร์มสอง
ใส่คำสั่งในปุ่มของฟอร์มหนึ่งว่า 
For Each f As Object In MDIParent1.MdiChildren : If UCase(f.name) = "FORM2" Then : Dim f2 As Form2 = f : 
f2.TextBox1.Text = Me.TextBox1.Text : MsgBox("wait") : f2.Close() : End If : Next
 กรณีที่ 2 ทดสอบตามที่หัวหน้าแนะนำให้ใช้ application.openforms
โดยสั่งจากฟอร์มสองแต่มีผลในฟอร์มหนึ่ง โดยใส่คำสั่งในปุ่มของฟอร์มสองว่า
Dim f As Form : f = Application.OpenForms.Item("form1") : For Each i As Object In f.Controls : If UCase(i.name) = 
"TEXTBOX1" Then : i.text = "abc" : End If : Next : MsgBox("wait") : f.Close()
 ขั้นตอนที่ 3 อธิบายความแตกต่าง
ทั้ง 2 กรณีต่างกันที่ กรณีที่ 1 อ้างอิงฟอร์มเป้าหมายผ่าน mdiparent1 แล้ววนลูปตาม object ทั้งหมดในนั้น
โดยมองหาวัตถุที่ชื่อ FORM2 เมื่อพบก็จะส่งเข้าวัตถุชิ้นใหม่ให้อ้างอิง แล้วจึงเรียกใช้ textbox1 ตามวัตถุประสงค์
แต่กรณีที่ 2 อ้างอิงฟอร์มเป้าหมายผ่าน Application.Openforms ซึ่งเรารู้ว่า Form1 เปิดอยู่ แล้วก็วนลูปเข้าไปใน controls ทั้งหมด
เมื่อพบ textbox1 ก็ดำเนินการทันที
 |  
 
ตัวอย่างการทำงานของ 
- ListBox
- ComboBox
- DataGridView
- select from .mdb
- ตัวอย่างใน nwindnet1.htm
  |  
 |  
 
ตัวอย่างรหัสต้นฉบับการใช้ ComboBox Class 
 ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/CPref17/html/T_System_Windows_Forms_ComboBox.htm
 |  Imports System.Windows.Forms
Inherits System.Windows.Forms.Form
Private addButton As System.Windows.Forms.Button
Private textBox2 As System.Windows.Forms.TextBox
Private addGrandButton As System.Windows.Forms.Button
Private comboBox1 As System.Windows.Forms.ComboBox
Private showSelectedButton As System.Windows.Forms.Button
Private textBox1 As System.Windows.Forms.TextBox
Private findButton As System.Windows.Forms.Button
Private label1 As System.Windows.Forms.Label
Public Sub New()
MyBase.New()
Me.InitializeComponent()
End Sub
<System.STAThreadAttribute()> Public Shared Sub Main()
System.Windows.Forms.Application.Run(New ComboBoxSample())
End Sub
Private Sub InitializeComponent()
Me.addButton = New System.Windows.Forms.Button()
Me.textBox2 = New System.Windows.Forms.TextBox()
Me.addGrandButton = New System.Windows.Forms.Button()
Me.comboBox1 = New System.Windows.Forms.ComboBox()
Me.showSelectedButton = New System.Windows.Forms.Button()
Me.textBox1 = New System.Windows.Forms.TextBox()
Me.findButton = New System.Windows.Forms.Button()
Me.label1 = New System.Windows.Forms.Label()
Me.addButton.Location = New System.Drawing.Point(248, 32)
Me.addButton.Size = New System.Drawing.Size(40, 24)
Me.addButton.TabIndex = 1
Me.addButton.Text = "Add"
AddHandler Me.addButton.Click, AddressOf Me.addButton_Click
Me.textBox2.Location = New System.Drawing.Point(8, 64)
Me.textBox2.Size = New System.Drawing.Size(232, 20)
Me.textBox2.TabIndex = 6
Me.textBox2.Text = ""
Me.addGrandButton.Location = New System.Drawing.Point(8, 96)
Me.addGrandButton.Size = New System.Drawing.Size(280, 23)
Me.addGrandButton.TabIndex = 2
Me.addGrandButton.Text = "Add 1,000 Items"
AddHandler Me.addGrandButton.Click, AddressOf Me.addGrandButton_Click
Me.comboBox1.DropDownWidth = 280
Me.comboBox1.Items.AddRange(New Object() {"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"})
Me.comboBox1.Location = New System.Drawing.Point(8, 248)
Me.comboBox1.Size = New System.Drawing.Size(280, 21)
Me.comboBox1.TabIndex = 7
Me.showSelectedButton.Location = New System.Drawing.Point(8, 128)
Me.showSelectedButton.Size = New System.Drawing.Size(280, 24)
Me.showSelectedButton.TabIndex = 4
Me.showSelectedButton.Text = "What Item is Selected?"
AddHandler Me.showSelectedButton.Click, AddressOf Me.showSelectedButton_Click
Me.textBox1.Location = New System.Drawing.Point(8, 32)
Me.textBox1.Size = New System.Drawing.Size(232, 20)
Me.textBox1.TabIndex = 5
Me.textBox1.Text = ""
Me.findButton.Location = New System.Drawing.Point(248, 64)
Me.findButton.Size = New System.Drawing.Size(40, 24)
Me.findButton.TabIndex = 3
Me.findButton.Text = "Find"
AddHandler Me.findButton.Click, AddressOf Me.findButton_Click
Me.label1.Location = New System.Drawing.Point(8, 224)
Me.label1.Size = New System.Drawing.Size(144, 23)
Me.label1.TabIndex = 0
Me.label1.Text = "Test ComboBox"
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {
Me.comboBox1, Me.textBox2, Me.textBox1, Me.showSelectedButton, Me.findButton, _
Me.addGrandButton, Me.addButton, Me.label1
})
Me.Text = "ComboBox Sample"
End Sub
Private Sub addButton_Click ( ...
comboBox1.Items.Add(textBox1.Text)
End Sub
Private Sub findButton_Click ( ...
Dim index As Integer
index = comboBox1.FindString(textBox2.Text)
comboBox1.SelectedIndex = index
End Sub
Private Sub addGrandButton_Click ( ...
comboBox1.BeginUpdate()
Dim I As Integer
For I = 0 To 1000
comboBox1.Items.Add("Item 1" + i.ToString())
Next
comboBox1.EndUpdate()
End Sub
Private Sub showSelectedButton_Click ( ...
Dim selectedIndex As Integer
selectedIndex = comboBox1.SelectedIndex
Dim selectedItem As Object
selectedItem = comboBox1.SelectedItem
MessageBox.Show("Selected Item Text: " & selectedItem.ToString() & _
Microsoft.VisualBasic.Constants.vbCrLf & "Index: " & selectedIndex.ToString())
End Sub
 |   
 |