Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

Setselected for listbox works with debug but not with Release mode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rnes1961@hotmail.com - 30 Jun 2005 05:27 GMT
I am using SetSelected to set a selected value on a listbox.

...
Console.Write("Ans 1: " & IntAns
lbAns1.SetSelected(IntAns, True)
Console.WriteLine(" Selected: " & lbAns1.SelectedIndex)
...

Where IntAns is an integer.

The thing is, it works just fine if I am in debug mode with a
breakpoint set anywhere.  But if I take the breakpoint off, the index
does not get set.

Below is the results WITH a breakpoint set.

...
Ans 1: 3 Selected: 3
...

With NO breakpoint set

...
Ans 1: 3 Selected: 0
...

As you can see by the console.write commands the index gets set when a
breakpoint is set but not when the breakpoint is not set.

HELLPPP!!! I am at the end of my rope, with a target date looming.
Jani Järvinen [MVP] - 30 Jun 2005 15:25 GMT
>I am using SetSelected to set a selected value on a listbox.
>
> The thing is, it works just fine if I am in debug mode with a
> breakpoint set anywhere.  But if I take the breakpoint off, the index
> does not get set.

Breakpoints and/or Release builds should not change the way a ListBox
behaves. So there is something else going on in your application.

Could you share a bit more information about your application? You mention
using Console.WriteLine calls. Are you still writing a Windows Forms
application? Is the listbox working okay interactively?

Note that if you manipulate components with a user interface (like ListBox)
in a piece of code, the UI might not be immediately updated unless you
implicitly or explicitly call Application.DoEvents. This might have bitten
you this time. Is the code you showed part of a larger code block? How and
when is the code executed?

Again, more information would be needed to solve the issue you are having.

Signature

Regards,

Mr. Jani Järvinen
C# MVP
Helsinki, Finland
janij@removethis.dystopia.fi
http://www.saunalahti.fi/janij/

rnes1961@hotmail.com - 01 Jul 2005 03:17 GMT
I found the problem.  I was trying to update the listbox in the
constructor.  I moved it to the page_load and now its working.

Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.