Tag Archives: Listbox

How to Stop Listbox Flicker in VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 

I see some persons mentioning that their .NET Listbox is flickering when they add alot of items. There is a easy work around that will stop that from happening. The ‘Listbox.BeginUpdate’ and ‘Listbox.EndUpdate’ subs should do the trick.  All you have to do is call the Listbox.BeginUpdate sub before you start adding items, and then call the Listbox.EndUpdate sub after you’ve added your items. BeginUpdate suspends the Listbox control from drawing/redrawing. So while you are adding items, calling this sub before you begin adding items will keep the listbox from showing the items until you call the EndUpdate sub. And likewise calling the EndUpdate sub will then allow the Listbox to redraw showing the items that you’ve added to it. Below is a simple example…


 

Listbox1.BeginUpdate()

Listbox1.Items.Add(“All of My Items))

Listbox1.EndUpdate

Thats all there is to it 🙂

Jason H

Add ‘all’ Date/Time Formats to Listbox/Combobox – VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 


This will add all of the available Date and Time formats to a listbox control or to a combobox control. This works for all versions of Visual Basic.NET.

 

        'Should add all of the available Date and Time formats to a combobox or listbox control.

        Dim dateTime As DateTime = New DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, Now.Second)

        Dim d() As String = Nothing

        d = dateTime.GetDateTimeFormats()

        ListBox1.Items.AddRange(d)

 

Find/Search for a String in a Listbox/Combobox control by using VB.NET

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 

This will search for a String value in the Listbox or Combobox items in Visual Basic.NET, VB 2005 and Higher

            '
            'TxtItem.Text would be a textbox control whose text string will be searched. And of course, lstItems
            'is a Listbox control or you can make it a Combobox control. The code below shows searching
            'for a  partial/exact string at either the beginning of the control or at a specified Index value.
            '
            'Search a Listbox Control for a exact string
            lstItems.SelectedIndex = lstItems.FindStringExact(txtItem.Text)
            '
            'Search a Listbox Control for a partial string
            lstItems.SelectedIndex = lstItems.FindString(txtItem.Text)

Add all Known GDI+ Web Colors to a Combobox or Listbox control.

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 

This will add the list of all known colors to a combobox or listbox control.

Imports System.Drawing

'

Dim kColor As KnownColor

For kColor = KnownColor.AliceBlue To KnownColor.YellowGreen 

  Combobox1.Items.Add(kColor)

Next

Add all Date and Time Formats to Listbox or Combobox using VB.NET and Higher

Click Star to Rate Post
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
 

This will add all of the available Date and Time formats to a Listbox or Combobox control. This works for all versions of Visual Basic.NET.

 

        '
        'Should add all of the available Date and Time formats to a combobox or listbox control.
        '
        Dim dateTime As DateTime = New  _
                DateTime(Now.Year, Now.Month, Now.Day, Now.Hour, Now.Minute, Now.Second)

        Dim d() As String = Nothing

        d = DateTime.GetDateTimeFormats()

        ListBox.Items.AddRange(d)