473,396 Members | 1,743 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,396 software developers and data experts.

Skipping the SelectedIndexChanged event

I've got a combo box that has an event handler set for
SelectedIndexChanged event. The problem is that it's
firing at startup when I load data from the Form_OnLoad
event. I tried setting a flag at startup and turning it
off at the end of the OnLoad function but the
SelectedIndexChange event gets called after OnLoad
finishes, so my flag is off. How can I get around this?
Is there another event that I can use to turn the flag
off? Or assign my SelectedIndexChanged event handler there
instead of InitializeComponent?
Nov 15 '05 #1
3 7980
Perhaps this is too simple of an answer, but is your
problem that you don't want the event to fire the first
time the form loads up? You can do that by checking for
ISPostBack:

void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
stuff you only want to do each time the form
is submitted;
...
}
else
{
Do the stuff you want to do when the page initially
loads...
...
)
}

You can also do the reverse... check for (!IsPostBack) if
you have code you only want to execute when the page
initially loads.

(again, I'm not sure if this is what you are asking for or
not...)
-----Original Message-----
I've got a combo box that has an event handler set for
SelectedIndexChanged event. The problem is that it's
firing at startup when I load data from the Form_OnLoad
event. I tried setting a flag at startup and turning it
off at the end of the OnLoad function but the
SelectedIndexChange event gets called after OnLoad
finishes, so my flag is off. How can I get around this?
Is there another event that I can use to turn the flag
off? Or assign my SelectedIndexChanged event handler thereinstead of InitializeComponent?
.

Nov 15 '05 #2
Delete the event - declaration (this.DropDown1.SelectedIndexChanged += new
System.EventHandler...) from the InitalizeCompontent() function, and add it
after the Loading of the DropDown

GP

"bpschmid" <bp******@hotmail.com> wrote in message
news:08****************************@phx.gbl...
Perhaps this is too simple of an answer, but is your
problem that you don't want the event to fire the first
time the form loads up? You can do that by checking for
ISPostBack:

void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
stuff you only want to do each time the form
is submitted;
...
}
else
{
Do the stuff you want to do when the page initially
loads...
...
)
}

You can also do the reverse... check for (!IsPostBack) if
you have code you only want to execute when the page
initially loads.

(again, I'm not sure if this is what you are asking for or
not...)
-----Original Message-----
I've got a combo box that has an event handler set for
SelectedIndexChanged event. The problem is that it's
firing at startup when I load data from the Form_OnLoad
event. I tried setting a flag at startup and turning it
off at the end of the OnLoad function but the
SelectedIndexChange event gets called after OnLoad
finishes, so my flag is off. How can I get around this?
Is there another event that I can use to turn the flag
off? Or assign my SelectedIndexChanged event handler

there
instead of InitializeComponent?
.

Nov 15 '05 #3
Never mind ... I found out what the problem is: there's a
bug in the tabcontrol (KnowledgeBase Article 820633) that
calls a bunch of ComboBox events including this one. So I
had to change the event handler code so it didn't cause
problems. Thanks for your help.
-----Original Message-----
I moved the assignment to the Form_onLoad function but
that's not working either. The SelectedIndexChange event
still gets fired as soon as OnLoad finishes. All I'm
doing to load the combo box is fill a dataset (it's a
bound control), so what's causing the SelectedIndex to
change?
-----Original Message-----
Delete the event - declaration(this.DropDown1.SelectedIndexChanged += new
System.EventHandler...) from the InitalizeCompontent()

function, and add it
after the Loading of the DropDown

GP

"bpschmid" <bp******@hotmail.com> wrote in message
news:08****************************@phx.gbl...
Perhaps this is too simple of an answer, but is your
problem that you don't want the event to fire the first
time the form loads up? You can do that by checking for
ISPostBack:

void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
stuff you only want to do each time the form
is submitted;
...
}
else
{
Do the stuff you want to do when the page initially
loads...
...
)
}

You can also do the reverse... check for (!IsPostBack)if you have code you only want to execute when the page
initially loads.

(again, I'm not sure if this is what you are asking foror
not...)

>-----Original Message-----
>I've got a combo box that has an event handler set for
>SelectedIndexChanged event. The problem is that it's
>firing at startup when I load data from the
Form_OnLoad >event. I tried setting a flag at startup and turning

it >off at the end of the OnLoad function but the
>SelectedIndexChange event gets called after OnLoad
>finishes, so my flag is off. How can I get aroundthis? >Is there another event that I can use to turn the flag
>off? Or assign my SelectedIndexChanged event handler
there
>instead of InitializeComponent?
>.
>

.

.

Nov 15 '05 #4

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

Similar topics

0
by: PeacError | last post by:
Using Microsoft Visual Studio .NET 2003, Visual C# .NET 1.1: I apologize if this question has been addressed elsewhere, but I could not find a reference to it in the search engine for this...
0
by: tafpin | last post by:
I have an application with a datagrid. In the IDE I have 2 template columns. The first has an image button and the second contains a link button. According to the results that I get back I must...
3
by: Alec MacLean | last post by:
Hi, I have a couple of win forms where I am editing values that are stored in a SQL database. I'm using the listbox control to hold the data object each form interacts with. Each object is...
2
by: jnoody | last post by:
The problem I am having is with the SelectedIndexChanged event not always firing or the SelectedIndex property not being correct when the event does fire. The code is below, but here are some...
11
by: J055 | last post by:
Hi I have a dropdown control which is constructed in another dropdown control SelectedIndexChanged event protected void ddlParamType_SelectedIndexChanged(object sender, EventArgs e) { //...
6
by: tbrown | last post by:
I have a combobox with items like this: {one,two,three}. The selected index is 0, so "one" appears in the combobox text. When the user drops down the list, and selects "two", for example, I...
4
by: lakepeir | last post by:
Hello, I have combobox with a selectedindexchanged method that seems to be called when starting the application, launching the form with the combobox and making a change in the drop down box of...
0
by: BillCo | last post by:
I'm a C# Newbie, so if I've missed the obvious here go easy!!! I have a form opened from a MDI parent. The form has a data bound combo box, with a SelectedIndexChanged event (fills a list view...
0
by: Hillbilly | last post by:
ItemBuilderWizard Step0_ItemTitle and Step2_ItemDescripton contain two TextBoxes and I've done some validation for those TextBoxes in an SelectedIndexChanged event handler that sets the...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.