473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Change the position of the item in listBox

I have list box populated with the dataReader. Then I add one item and I
want that this item would be the first one in the listBox.
Now, It's the last. Can I change the position of the item in the listBox
from the last to the first?
lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()

Dim novItem As New ListItem

novItem.Text = "..."
novItem.Value = "0"
novItem.Selected = True
lstMedia.Items.Add(novItem)
Nov 18 '05 #1
2 2778
Hi Simon,
You can try one of the following
lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()
lstMedia.items.insert(0,"Mohamed") ' If you don't want to add value

or
dim myListItem as new ListItem("Mohamed","150") 'if you want to add a
value to the item
lstMedia.items.insert(0,myListItem)

Best Regards
Mohamed Sharaf

"simon" <si*********@stud-moderna.si> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
I have list box populated with the dataReader. Then I add one item and I
want that this item would be the first one in the listBox.
Now, It's the last. Can I change the position of the item in the listBox
from the last to the first?
lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()

Dim novItem As New ListItem

novItem.Text = "..."
novItem.Value = "0"
novItem.Selected = True
lstMedia.Items.Add(novItem)

Nov 18 '05 #2
thank you, it works now.
I missed the method insert, I only new for add method:)

Regards,
Simon

"Mohamed Sharaf" <mo************@GOAWAYitworx.com.PRIVACY> wrote in message
news:Ow**************@TK2MSFTNGP10.phx.gbl...
Hi Simon,
You can try one of the following
lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()
lstMedia.items.insert(0,"Mohamed") ' If you don't want to add value

or
dim myListItem as new ListItem("Mohamed","150") 'if you want to add a
value to the item
lstMedia.items.insert(0,myListItem)

Best Regards
Mohamed Sharaf

"simon" <si*********@stud-moderna.si> wrote in message
news:eN**************@TK2MSFTNGP10.phx.gbl...
I have list box populated with the dataReader. Then I add one item and I
want that this item would be the first one in the listBox.
Now, It's the last. Can I change the position of the item in the listBox
from the last to the first?
lstMedia.DataSource() = funkcije.createDataReader(sql, True)
lstMedia.DataValueField = "med_id"
lstMedia.DataTextField = "med_name"
lstMedia.DataBind()

Dim novItem As New ListItem

novItem.Text = "..."
novItem.Value = "0"
novItem.Selected = True
lstMedia.Items.Add(novItem)


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Irene | last post by:
I'm developing a Web application where a user selects from a listbox which can have many items. The initial display only shows about 10 items. After a postback, the listbox is automatically...
3
by: SamIAm | last post by:
Hi I have a ListBox called lstListOfStuff I want to get the ordinal position of a ListItem so that I can insert a new ListItem below it. How do I do this? I cannot find any members to give me...
3
by: Alpha | last post by:
I have 3 radio buttons for include, exclued or 'select all' from the listbox items. If a user selects the 'Select All' button' then all items in listbox is hi-lited as selected. Now, when user...
1
by: Karen Grube | last post by:
Hi! I'm using a standard server side ASP.Net listbox control on a web form. The page is basically various shades of green. The listbox itself has a pale green background and forest green text...
3
by: Giovanni Bassi | last post by:
Hello All, I have a class implementing IList and a global object of this class type. I have two different form objects. One has a ListBox and the other has ComboBox. Both of their datasources...
5
by: Joe Fallon | last post by:
I have a list box with 7 text values in it. I have a pair of buttons to Move Up or Move Down the selected item one position. What is the simplest way to code the buttons so the item moves one...
5
by: Randy | last post by:
Hi, I'm have a form with a listbox and a few textboxes on it. Based on the user's selection in the listbox, I want the bindingsource to update the textboxes with the corresponding values. I have...
7
by: Lit | last post by:
Hi, How can I capture the vertical scroll bar position for a Listbox. I have a Listbox of 100 items + when I click on it I post back remove the item selected. After returning to the client...
3
by: CSharper | last post by:
Is it possible to selectivly change the color of an item in text. I saw ForeColor option, but it changes the color of all the items. If it is not possible, is there any other control list listbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.