Off-topic Talk Where overpaid, underworked S2000 owners waste the worst part of their days before the drive home. This forum is for general chit chat and discussions not covered by the other off-topic forums.

Programming questions

Old Dec 14, 2005 | 11:08 AM
  #1  
stockae92's Avatar
Thread Starter
Registered User
 
Joined: Nov 2001
Posts: 6,006
Likes: 0
From: socal
Default Programming questions

for C# in .NET

in the .cs code behind file, can i highlight (select) items in a ListBox?

i need to select items in a ListBox in the .cs file

is there a property like that?

thanks in advance
Reply
Old Dec 15, 2005 | 07:22 AM
  #2  
Gink5's Avatar
Registered User
 
Joined: Aug 2004
Posts: 1,620
Likes: 0
From: Newtown,PA
Default

I'm sure i can help if you rephrase the question. It seems you are trying to open the file with the code? or are yuo trying to make a list box and select multiple items at once?
Reply
Old Dec 15, 2005 | 07:33 AM
  #3  
cyber_x's Avatar
Registered User
 
Joined: Jun 2002
Posts: 4,096
Likes: 0
From: SF Bay Area
Default

i work mostly with win32 api stuff, so dunno much about c#, but in most cases the items in a listbox should be an array. try something like this:

listbox.items[0].selected = true;

could be a bit screwed up, but to do whatever it is you're going for, you almost certainly need to access the items[] array.
Reply
Old Dec 15, 2005 | 07:51 AM
  #4  
Gink5's Avatar
Registered User
 
Joined: Aug 2004
Posts: 1,620
Likes: 0
From: Newtown,PA
Default

c# looks alot like java
Reply
Old Dec 15, 2005 | 07:52 AM
  #5  
cyber_x's Avatar
Registered User
 
Joined: Jun 2002
Posts: 4,096
Likes: 0
From: SF Bay Area
Default

ok looks like i did have a c# tool on my system after all. you can do it by the item name like so:

listBox.SelectedItem = "your item";

or you can do it by the item's position in the array, collection, or whatever it's called in c#:

listBox.SelectedIndex = 2;
Reply
Old Dec 15, 2005 | 07:58 AM
  #6  
Gink5's Avatar
Registered User
 
Joined: Aug 2004
Posts: 1,620
Likes: 0
From: Newtown,PA
Default

[QUOTE=cyber_x,Dec 15 2005, 08:52 AM] ok looks like i did have a c# tool on my system after all.
Reply
Old Dec 15, 2005 | 08:05 AM
  #7  
cyber_x's Avatar
Registered User
 
Joined: Jun 2002
Posts: 4,096
Likes: 0
From: SF Bay Area
Default

i figured he's using winforms (because of the ".cs code behind file" part) and just wants to write the code to highlight a listbox item

sent ya a pm regarding your question
Reply
Old Dec 15, 2005 | 08:27 AM
  #8  
stockae92's Avatar
Thread Starter
Registered User
 
Joined: Nov 2001
Posts: 6,006
Likes: 0
From: socal
Default

ops, i found a way

to select all listbox items:

foreach(ListItem i in ListBox.Items)
{
i.Selected = true;
}


and i assume i can do something like this:

ListBox[i].Selected = true

to select a certain item(s) in the ListBox

Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Anuj
NYC Metro Off Topic
6
Mar 16, 2010 10:57 AM
s2kdriver80
Off-topic Talk
1
May 30, 2003 03:36 PM
mingster
Off-topic Talk
5
Apr 11, 2001 09:26 PM



All times are GMT -8. The time now is 09:47 PM.