473,789 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Skipping the SelectedIndexCh anged event

I've got a combo box that has an event handler set for
SelectedIndexCh anged 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
SelectedIndexCh ange 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 SelectedIndexCh anged event handler there
instead of InitializeCompo nent?
Nov 15 '05 #1
3 8000
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(objec t 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
SelectedIndexC hanged 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
SelectedIndexC hange 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 SelectedIndexCh anged event handler thereinstead of InitializeCompo nent?
.

Nov 15 '05 #2
Delete the event - declaration (this.DropDown1 .SelectedIndexC hanged += new
System.EventHan dler...) from the InitalizeCompon tent() function, and add it
after the Loading of the DropDown

GP

"bpschmid" <bp******@hotma il.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(objec t 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
SelectedIndexC hanged 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
SelectedIndexC hange 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 SelectedIndexCh anged event handler

there
instead of InitializeCompo nent?
.

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 SelectedIndexCh ange 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.DropDown 1.SelectedIndex Changed += new
System.EventH andler...) from the InitalizeCompon tent()

function, and add it
after the Loading of the DropDown

GP

"bpschmid" <bp******@hotma il.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(objec t 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
>SelectedIndexC hanged 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
>SelectedIndexC hange 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 SelectedIndexCh anged event handler
there
>instead of InitializeCompo nent?
>.
>

.

.

Nov 15 '05 #4

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

Similar topics

0
5424
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 board. I have a form that contains a ListView and a GroupBox control. The GroupBox control itself contains several TextBox Controls. I have Validating and Validated event handlers set for the GroupBox control, and a SelectedIndexChanged event...
0
1759
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 add more columns to the datagrid. This is a sample of how I am adding these colums: templateColumn = New TemplateColumn
3
2634
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 defined by my own classes. On the first form, I use an approach to reduce the number of database calls. This essentially consists of :
2
3305
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 details first. The DropDownList is actually a custom control called DropDownListWithCommandEvent that inherits from DropDownList. The reason I have created this is to create a DropDownList that will bubble a Command event to the containing...
11
37001
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) { // some other code DropDownList ddlGroups = new DropDownList(); ddlGroups.SelectedIndexChanged += new
6
10822
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 modify the Items collection to be {two,one,three} and now want "two" to appear in the combobox text. However, the combobox text is now blank. the is apparently somehow the result of having changed the combobox.Items collection. If, trying to fix...
4
5257
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 the combobox. Can anyone tell me why the method is called so often? I would only like the method executed when a user makes a change in the drop down box. Am I using the incorrect method. Thanks.
0
2020
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 box on the same form depending on selection). It all works fine except when you close either the form itself or it's MDI parent. Somehow as the form is closing this event is triggered, and crashes out with an un- handled error (even though it's in...
0
1017
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 ItemBuilderWizard.ActiveStepIndex to return to Step0_ItemTitle when a validation rule is not met. The SelectedIndexChanged event is raised by a list control that is displayed using client-side code. Generally, once the list control is displayed it can be...
0
9659
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9504
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10400
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10190
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9977
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9011
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5545
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4084
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3692
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.