Click here to Skip to main content
15,901,373 members
Home / Discussions / C#
   

C#

 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
PIEBALDconsult15-Dec-10 7:40
mvePIEBALDconsult15-Dec-10 7:40 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Brady Kelly15-Dec-10 19:39
Brady Kelly15-Dec-10 19:39 
AnswerRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff22-Oct-10 23:39
mveOriginalGriff22-Oct-10 23:39 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
Luc Pattyn23-Oct-10 2:45
sitebuilderLuc Pattyn23-Oct-10 2:45 
GeneralRe: Parsing csv file with commas and quotes as deliminators Pin
OriginalGriff23-Oct-10 3:43
mveOriginalGriff23-Oct-10 3:43 
QuestionClose Pop Up windows Pin
SatyaKeerthi1522-Oct-10 3:11
SatyaKeerthi1522-Oct-10 3:11 
AnswerRe: Close Pop Up windows Pin
Not Active22-Oct-10 3:22
mentorNot Active22-Oct-10 3:22 
QuestionAnnoying ListBox problem [SOLVED] Pin
Henry Minute22-Oct-10 3:10
Henry Minute22-Oct-10 3:10 
I have a ListBox with SelectionMode.MultiExtended.

I add an item programatically and set it as selected. I want it to be the sole selection.

I have tried Clear() on all the Selectedxxx collections, set all the individual Selectedxxx properties to values which should deselect any current selections. I have tried iterating over the SelectedIndices and using SetSelected(x, false) all to no avail, whatever was selected before the addition remains selected highlighted afterwards.

I have resolved the problem by setting the SelectionMode to SelectionMode.One, SelectedIndex to -1, making the addition reverting the SelectionMode and selecting the added item.

Code:
C#
this.lboxEntries.SelectionMode = SelectionMode.One;
this.lboxEntries.SelectedIndex = -1;
this.data.Add(this.txtEditEntry.Text);
RefreshDataBoundControls();
this.lboxEntries.SelectedIndex = data.Count - 1;
this.lboxEntries.SelectionMode = SelectionMode.MultiExtended;


This seems unnecessarily convoluted.

Any one have a more direct method?
Henry Minute

Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
modified on Friday, October 22, 2010 1:08 PM

AnswerRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 4:35
sitebuilderLuc Pattyn22-Oct-10 4:35 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 4:42
mveOriginalGriff22-Oct-10 4:42 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:16
sitebuilderLuc Pattyn22-Oct-10 5:16 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 4:46
Henry Minute22-Oct-10 4:46 
AnswerRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:13
sitebuilderLuc Pattyn22-Oct-10 5:13 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 5:14
mveOriginalGriff22-Oct-10 5:14 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:17
sitebuilderLuc Pattyn22-Oct-10 5:17 
GeneralRe: Annoying ListBox problem Pin
OriginalGriff22-Oct-10 5:24
mveOriginalGriff22-Oct-10 5:24 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:19
sitebuilderLuc Pattyn22-Oct-10 5:19 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 5:30
Henry Minute22-Oct-10 5:30 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 5:59
sitebuilderLuc Pattyn22-Oct-10 5:59 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 6:06
Henry Minute22-Oct-10 6:06 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 6:48
Henry Minute22-Oct-10 6:48 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 7:08
Henry Minute22-Oct-10 7:08 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 7:33
sitebuilderLuc Pattyn22-Oct-10 7:33 
GeneralRe: Annoying ListBox problem Pin
Henry Minute22-Oct-10 7:41
Henry Minute22-Oct-10 7:41 
GeneralRe: Annoying ListBox problem Pin
Luc Pattyn22-Oct-10 14:36
sitebuilderLuc Pattyn22-Oct-10 14:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.