HOW TO GET THE SELECTED ITEM(S) IN A LIST VIEW CONTROL ListView returns collections of selected items and indices through the SelectedItems and SelectedIndices properties. Note that these collections are empty, if no item is currently selected( lst.SelectedItems.Count == 0 ).The first item that is selected is lst.SelectedItems[0] The index of this item in the Items collection islst.SelectedIndices[0] .So basically
is the same as
You can also use check boxes. Set CheckBoxes to true for this. Through the CheckedItems and CheckedIndices properties you can see which items are checked. |
This blog aims to help visual basic .net programmers meet solutions to some everyday programming issues.
Saturday, February 2, 2013
HOW TO GET THE SELECTED ITEM(S) IN A LIST VIEW CONTROL
KEYPRESS EVENT IN VB.NET
Handle Keyboard Input at the Form Level in VB.NET
Windows Forms processes keyboard input by raising
keyboard events in response to Windows messages. Most Windows Forms
programs process keyboard input by handling the keyboard events.
How do I detect keys pressed in VB.NET
You can detect most physical key presses by handling the KeyDown or KeyUp events. Key events occur in the following order:
KeyDown
KeyPress
KeyUp
How to detect when the Enter Key Pressed in VB.NET
The following VB.NET code behind creates the
KeyDown event handler. If the key that is pressed is the Enter key, a
MessegeBox will displayed .
If e.KeyCode = Keys.Enter Then
MsgBox("enter key pressd ")
End If
How to get TextBox1_KeyDown event in your VB.Net source file ?
Select your VB.Net source code view in Visual
Studio and select TextBox1 from the top-left Combobox and select KeyDown
from top-right combobox , then you will get keydown event sub-routine
in your source code editor.
Private Sub TextBox1_KeyDown(...)..
End Sub
The following VB.NET source code shows how to capture Enter KeyDown event from a TextBox Control.
How to: Print a Form by Using the PrintForm Component (Visual Basic)
The PrintForm component enables you to quickly print an image of a form exactly as it appears on screen without using a PrintDocument
component. The following procedures show how to print a form to a
printer, to a print preview window, and to an Encapsulated PostScript
file.
To print a form to the default printer
-
In the Toolbox, click the Visual Basic PowerPacks tab and then drag the PrintForm component onto the form.
The PrintForm component is added to the component tray.
-
In the Properties window, set the PrintAction property to PrintToPrinter.
-
Add the following code in the appropriate event handler (for example, in the Click event handler for a Print Button).
PrintForm1.Print()
To display a form in a print preview window
-
In the Toolbox, click the Visual Basic PowerPacks tab and then drag the PrintForm component onto the form.
The PrintForm component is added to the component tray.
-
In the Properties window, set the PrintAction property to PrintToPreview.
-
Add the following code in the appropriate event handler (for example, in the Click event handler for a Print Button).
PrintForm1.Print()
To print a form to a file
-
In the Toolbox, click the Visual Basic PowerPacks tab and then drag the PrintForm component onto the form.
The PrintForm component is added to the component tray.
-
In the Properties window, set the PrintAction property to PrintToFile.
-
Optionally, select the PrintFileName property and type the full path and file name for the destination file.
If you skip this step, the user will be prompted for a file name at run time.
-
Add the following code in the appropriate event handler (for example, in the Click event handler for a Print Button).
Subscribe to:
Posts (Atom)