Ücretsiz Hosting için tıklayınız....
Bu alan adları için tıklayınız....
Bu alan adları için tıklayınız.....

<Application .../>
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="SDKSample.App" />
C#
using System.Windows; // Application namespace SDKSample { public partial class App : Application { }..............................................................................................................................................
<Application .../>

public ref class Application : public DispatcherObject, IQueryAmbient
<Application .../>
public class Application : DispatcherObject, IQueryAmbient
using System; // STAThread using System.Windows; // Application namespace SDKSample { public class AppCode : Application { // Entry point method [STAThread] public static void Main() { AppCode app = new AppCode(); app.Run(); } } }
'Declaration Public Sub New
The following code example demonstrates how to create a ListBox controlthat displays multiple items in columns and can have more than one itemselected in the control's list. The code for the example adds 50 itemsto the ListBox using the Add method of the ListBox::ObjectCollectionclass and then selects three items from the list using the SetSelectedmethod. The code then displays values from theListBox::SelectedObjectCollection collection, through the SelectedItemsproperty, and the ListBox::SelectedIndexCollection, through theSelectedIndices property. This example requires that the code is locatedin and called from a Form
Private Sub button1_Click(sender As Object, e As System.EventArgs) ' Create an instance of the ListBox. Dim listBox1 As New ListBox() ' Set the size and location of the ListBox. listBox1.Size = New System.Drawing.Size(200, 100) listBox1.Location = New System.Drawing.Point(10, 10) ' Add the ListBox to the form. Me.Controls.Add(listBox1) ' Set the ListBox to display items in multiple columns. listBox1.MultiColumn = True ' Set the selection mode to multiple and extended. listBox1.SelectionMode = SelectionMode.MultiExtended ' Shutdown the painting of the ListBox as items are added. listBox1.BeginUpdate() ' Loop through and add 50 items to the ListBox. Dim x As Integer For x = 1 To 50 listBox1.Items.Add("Item " & x.ToString()) Next x ' Allow the ListBox to repaint and display the new items. listBox1.EndUpdate() ' Select three items from the ListBox. listBox1.SetSelected(1, True) listBox1.SetSelected(3, True) listBox1.SetSelected(5, True) ' Display the second selected item in the ListBox to the console. System.Diagnostics.Debug.WriteLine(listBox1.SelectedItems(1).ToString()) ' Display the index of the first selected item in the ListBox. System.Diagnostics.Debug.WriteLine(listBox1.SelectedIndices(0).ToString()) End Sub
public ListBox()
private void button1_Click(object sender, System.EventArgs e) { // Create an instance of the ListBox. ListBox listBox1 = new ListBox(); // Set the size and location of the ListBox. listBox1.Size = new System.Drawing.Size(200, 100); listBox1.Location = new System.Drawing.Point(10,10); // Add the ListBox to the form. this.Controls.Add(listBox1); // Set the ListBox to display items in multiple columns. listBox1.MultiColumn = true; // Set the selection mode to multiple and extended. listBox1.SelectionMode = SelectionMode.MultiExtended; // Shutdown the painting of the ListBox as items are added. listBox1.BeginUpdate(); // Loop through and add 50 items to the ListBox. for (int x = 1; x <= 50; x++) { listBox1.Items.Add("Item " + x.ToString()); } // Allow the ListBox to repaint and display the new items. listBox1.EndUpdate(); // Select three items from the ListBox. listBox1.SetSelected(1, true); listBox1.SetSelected(3, true); listBox1.SetSelected(5, true); // Display the second selected item in the ListBox to the console. System.Diagnostics.Debug.WriteLine(listBox1.SelectedItems[1].ToString()); // Display the index of the first selected item in the ListBox. System.Diagnostics.Debug.WriteLine(listBox1.SelectedIndices[0].ToString()); }
referance:
https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.listbox(v=vs.110).aspx
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ListBox1
.Enabled = True 'if the listox is enable or disabled
.Sorted = True ' if you want ti list sorted
.BorderStyle = BorderStyle.Fixed3D ' the border style
.Visible = True
.ScrollAlwaysVisible = True 'presence of scroll all time
.MultiColumn = False 'add a new column if number of items reach max height
End With
End Sub
|
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ListBox1
.Enabled = True 'if the listox is enable or disabled
.Sorted = True ' if you want ti list sorted
.BorderStyle = BorderStyle.Fixed3D ' the border style
.Visible = True
.ScrollAlwaysVisible = True 'presence of scroll all time
.MultiColumn = False 'add a new column if number of items reach max height
End With
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
End Sub
|
ListBox1.SelectedIndex = 2 '0 is the first one, 2 is the third.
|
ListBox1.SelectedItem = "allo3" 'will always select the first he encounter
|
ListBox1.SelectionMode = SelectionMode.MultiSimple 'no need to use shift or ctrl, only space or left-click
ListBox1.SelectionMode = SelectionMode.MultiExtended 'no need to use shift or ctrl with left-click
|
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
End Sub
|
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox(ListBox1.SelectedIndex)
End Sub
|
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ListBox1
.Enabled = True 'if the listox is enable or disabled
.Sorted = True ' if you want ti list sorted
.BorderStyle = BorderStyle.Fixed3D ' the border style
.Visible = True
.ScrollAlwaysVisible = True 'presence of scroll all time
.MultiColumn = False 'add a new column if number of items reach max height
End With
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.SelectedIndex = 2 '0 is the first one, 2 is the third.
ListBox1.SelectedItem = "allo3" 'will always select the first he encounter
ListBox1.SelectionMode = SelectionMode.MultiSimple 'no need to use shift or ctrl, only space or left-click
ListBox1.SelectionMode = SelectionMode.MultiExtended 'no need to use shift or ctrl with left-click
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
MsgBox(ListBox1.SelectedIndex)
End Sub
End Class
|
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If form_onShow = True Then
'MsgBox(ListBox1.SelectedItem.ToString)
MsgBox(ListBox1.SelectedIndex)
End If
MsgBox(ListBox1.SelectedItem.ToString)
End Sub
|
Protected Overrides Sub OnShown(e As System.EventArgs)
MyBase.OnShown(e)
form_onShow = True
End Sub
|
Public Class Form1
Private form_onShow As Boolean 'variable member of Form1
Protected Overrides Sub OnShown(e As System.EventArgs)
MyBase.OnShown(e)
form_onShow = True
End Sub
…
…
…
|
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
form_onShow = False
End Sub
|
Public Class Form1
Private form_onShow As Boolean 'variable member of Form1
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
form_onShow = False
End Sub
Protected Overrides Sub OnShown(e As System.EventArgs)
MyBase.OnShown(e)
form_onShow = True
End Sub
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
With ListBox1
.Enabled = True 'if the listox is enable or disabled
.Sorted = True ' if you want ti list sorted
.BorderStyle = BorderStyle.Fixed3D ' the border style
.Visible = True
.ScrollAlwaysVisible = True 'presence of scroll all time
.MultiColumn = False 'add a new column if number of items reach max height
End With
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.Items.Add("allo1")
ListBox1.Items.Add("allo2")
ListBox1.Items.Add("allo3")
ListBox1.Items.Add("allo4")
ListBox1.Items.Add("allo5")
ListBox1.SelectedIndex = 2 '0 is the first one, 2 is the third.
ListBox1.SelectedItem = "allo3" 'will always select the first he encounter
ListBox1.SelectionMode = SelectionMode.MultiSimple 'no need to use shift or ctrl, only space or left-click
ListBox1.SelectionMode = SelectionMode.MultiExtended 'no need to use shift or ctrl with left-click
End Sub
Private Sub ListBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If form_onShow = True Then
'MsgBox(ListBox1.SelectedItem.ToString)
MsgBox(ListBox1.SelectedIndex)
End If
MsgBox(ListBox1.SelectedItem.ToString)
End Sub
End Class
|