Controls

There are two differences between the controls and the Office ActiveX controls
1) windows form controls are implemented by extensible managed classes. Office controls are unmanaged
2) windows form controls have no concept of their location in relation to the containing workbook or document
You can use this.Controls collection to enumerate through all the controls


BackgroundWorkerAllows the user to to execute an operation on a separate (dedicated) thread.
ButtonAllows the user to run a separate subroutine.
CheckBoxAllows the user to either select or deselect an option.
CheckedListBoxAllows the user to select multiple items from a list of items.
ComboBoxAllows the user to either select an item from a drop-down box or enter a different item.
DataGridViewAllows the user to display (and edit) a table of information.
DateTimePickerAllows the user to select a specific date and/or time.
DHTML Editing ControlAllows the user to display a web page (not supported).
FolderBrowseDialogAllows the user to browse, create and select folders (not files).
GroupBoxAllows you to group other controls together.
ImageListAllows you to have a repository of images in your assembly.
LabelAllows you to display text to the user.
LinkLabelAllows you to include hyperlinks in your text.
ListBoxAllows the user to select an item from a list of items.
ListViewAllows the user to select a single (or multiple) items from a list with multiple columns.
MenuStripAllows the user to group commands by a common theme.
NumericUpDownAllows the user to display numeric values.
PanelAllows the user an area for grouping controls and scrolling.
PictureBox(Image) Allows you to display a graphic or picture.
ProgressBarAllows the user to indicate progress using a graphical bar.
RadioButton(OptionButton) Allows the user to select from a list of possible distinct options.
RichTextBoxAllows the user to display text with formatting.
SplitContainerAllows you to split an area into two resizeable panels.
StatusStripAllows you to add a status bar to your window.
TabControlAllows you to display multiple tabs of the same controls.
TableLayoutPanel 
TextBox(EditBox) Allows you to display text and to allow the user to enter information.
ToolTipAllows you to display text when you hover over other controls.
ToolStripRepresents a panel in a StatusStrip control.
ToolStripButtonRepresents a selectable item for a ToolStrip control.
TreeViewAllows you to display a hierarchy of nodes with parents and child.
VScrollBarAllows the user to drag a button in order to select a value.
WebBrowserAllows the user to include a web browser on a form.


Toolbox

This window holds a list of controls that you can drag onto the forms. There are different sets of controls available, depending on the type of designer that is active, ie Windows Forms, Web Forms, XML document. If you wish to customise which tools are dipsplayed in the toolbox, or if you wish to add any additional .NET components, ActiveX controls or third party conttrols, click (Tools > Customise Toolbar)
There are several categories on the Toolbox



Docking of a control to the top, left, right or bottom of the container. You can also set the Dock property to DockStyle.Fill which will adjust the control to fill the container.


The Format menu allows you to:

  • Lock the controls on a form

  • Align selected controls with the primary control

  • Resize controls to the dimensions of the control selected last

  • Make equal, increase, decrease or rmeove the horizontal spacing between controls



Common Dialogs

ColorDialog
FileDialog
FontDialog
OpenFileDialog
PageSetupDialog
PrintDialog
PrintPreviewDialog
SaveFileDialog



(View > Tab Order)


If you set the Font property on a form, prior to adding any controls then all the controls will inherit the font style for the form
You can select all the controls using (Ctrl + "A")
You can lock the controls (Format > Lock Controls). This prevents any of the controls on the form being accidently moved.
(Format > Align)
Aligning controls is made a lot easier by having the grid on the form
The alignments and sizing options



Timer

This is an invisible stopwatch that gives you access to the system clock.
It can be used to count down from a preset time to cause a delay in a program or to repeat an action at prescribed intervals.
Although timer objects ate not visible at runtime, each timer is associated with an event procedure that runs every time the timer's preset interval has elapsed.




ActiveX Controls

You can easily expand the collection of controls that you have access to by loading ActiveX or COM controls.
When you add an ActiveX control to your Toolbox, Visual Studio displays them with the .NET controls and you can use them on your forms with few limitations. Visual Studio must create a wrapper for the control to enable it to be used in a .NET program.


FileOpenDialog


With dlgOpenFile 
   .CheckFileExists = True
   .Filter = "Design Templates (*.pot)|*.pot"

   If .ShowDialog = Windows.Forms.DialogResult.OK Then
      txtTemplatePath.Text = .FileName
   End If
End With



Me.tabMyTabControl.Controls.Find(key:="mytag", SearchAllChildren=True) 


In Visual Studio.NET, there are no drawing controls provided in the Toolbox. Instead you are encouraged to use GDI graphics services directly through the System.Drawing namespace.


bitmaps
icons


The System.Drawing namespace include numerous classes for creating graphics

LineDrawLine
RectangleDrawRectangle
ArcDrawArc
Circle / EllipseDrawEllipse
PolygonDrawPolygon
CurveDrawCurve
BeziersplinesDrawBezier



Overloading Handlers

Private Sub Control_OnEvent() Handles Control1.OnEvent, Control2.OnEvent 



What is a Custom Control ?

no user interface


Positioning Controls


When you add controls to a windows form the default mode is GridLayout
They will be arranged using absolute positioning (x,y) corodinates


The other mode is FlowLayout
Here the controls are added top to bottom
The mode can be changed using the PageLayout property.



Setting Focus


txtTextBox.Select() 


KB - 822493


Me.ActiveControl = Me.txtMyTextbox 
Me.txtMyTextbox.Focus





© 2017 Better Solutions Limited. All Rights Reserved. © 2017 Better Solutions Limited

PrevNext