Forms - Page 3

Most document-based applications typically allow to open a document file in two ways: with the Open File menu command / toolbar button, or by dragging and dropping the file from Windows Explorer to the application's window. This works with MS Word, Winzip and many other applications. ...

Return a reference to the control with the specified name, searched into the specified container and its sub-controls
Note: it requires the GetAllControls function
Example: get a reference to a Label named "lblTest", and set its Text property
DirectCast(FindControl("lblTest", Me), Label).

Insert an image into a RichTextBox, in the current position
This version takes in input the target RichTextBox and the path of the image to insert
Example: InsertImageIntoRtb(RichTextBox1, "C:\test.jpg")

It happens quite often that you have a DataGrid with hidden columns (with width = 0), because you need their values but don't want to show them to the user. However, when you tab through the DataGrid's columns, these "hidden" columns are still taken into account in the tab order. This means ...

Returns an array with all the controls in the specified container control and its child containers
Example:
print the name of all the controls on the form and its child container controls
Dim ctl As Control
For Each ctl In GetAllControls(Me)
Debug.WriteLine(ctl.Name)
Next

Return a validation summary string with all the error messages, if any, of the controls inside the specified container, associated to an ErrorProvider control
Example:
Dim summary As String = ""
display the validation summary for all the controls on the form
summary = GetValid

Returns an array of controls of the specified type, found within the specified parent control (or the form itself).
Note: the search is optionally done recursively, by checking also controls' child controls
Example: get an array with the form's textboxes
Dim textboxes() As TextBox = ...

Show a form with an explosion effect.
the numSteps parameter is the number of steps to increase the form size from 0 to the original size
the stepDuration argument is the number of milliseconds between each step
Example:
Private Sub Form1_Activated(...) Handles MyBase.Activated

Moves an item of a listbox to another index
If FROMINDEX = -1 then it moves the current highlighted item
Example:
move up the selected item
MoveListboxItem(ListBox1, -1, ListBox1.SelectedIndex - 1)
move down the selected item
MoveListboxItem(ListBox1, -1, ListBox1.SelectedIndex + 1)