473,834 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Databinding a ListBox fires multiple SelectedIndexCh anged events

Hi everyone,

I have a ComboBox that when changed, calls a method to change the content of
a ListBox.
I'm also using the Listbox's SelectedIndexCh anged event to change other
control values on the form.

(It's a Company -> People -> Personal Data relationship)

When I bind my datasource to the ListBox, I find that the
SelectedIndexCh anged event fires three times.
(I am using BeginUpdate / EndUpdate around the databinding statements.)

This multiple event firing causes the side effect of a form-flicker as the
last set of controls get cleared and set.

Is this normal behaviour for the ListBox when using databinding?

I do want the event to fire, but only after the databinding has completed
and only the one time.

Any help is appreciated.

Alec
Dec 2 '05 #1
3 7780
Alec,

There can be much reasons and always hard to show in a newsgroup (mostly you
need for that to much code), however prevent your listbox from selecting
when you find any data to it.

The beginupdate and endupdate does nothign in that, so you can do that by
setting a boolean when you do that and test that in the events from the
listbox, or just do removehandler and addhandler from those events what is
the nicest.

I hope this helps,

Cor

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> schreef in bericht
news:O0******** ******@TK2MSFTN GP14.phx.gbl...
Hi everyone,

I have a ComboBox that when changed, calls a method to change the content
of a ListBox.
I'm also using the Listbox's SelectedIndexCh anged event to change other
control values on the form.

(It's a Company -> People -> Personal Data relationship)

When I bind my datasource to the ListBox, I find that the
SelectedIndexCh anged event fires three times.
(I am using BeginUpdate / EndUpdate around the databinding statements.)

This multiple event firing causes the side effect of a form-flicker as the
last set of controls get cleared and set.

Is this normal behaviour for the ListBox when using databinding?

I do want the event to fire, but only after the databinding has completed
and only the one time.

Any help is appreciated.

Alec

Dec 3 '05 #2
Thanks Cor,

I've tried various approaches to resolving this - including your boolean
suggestion, but as yet nothing works quite how I'd like them to.

It's not an essential aspect, just a small tidying of the visual
presentation when the program loads.

Alec
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:u9******** ******@TK2MSFTN GP12.phx.gbl...
Alec,

There can be much reasons and always hard to show in a newsgroup (mostly
you need for that to much code), however prevent your listbox from
selecting when you find any data to it.

The beginupdate and endupdate does nothign in that, so you can do that by
setting a boolean when you do that and test that in the events from the
listbox, or just do removehandler and addhandler from those events what is
the nicest.

I hope this helps,

Cor

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> schreef in bericht
news:O0******** ******@TK2MSFTN GP14.phx.gbl...
Hi everyone,

I have a ComboBox that when changed, calls a method to change the content
of a ListBox.
I'm also using the Listbox's SelectedIndexCh anged event to change other
control values on the form.

(It's a Company -> People -> Personal Data relationship)

When I bind my datasource to the ListBox, I find that the
SelectedIndexCh anged event fires three times.
(I am using BeginUpdate / EndUpdate around the databinding statements.)

This multiple event firing causes the side effect of a form-flicker as
the last set of controls get cleared and set.

Is this normal behaviour for the ListBox when using databinding?

I do want the event to fire, but only after the databinding has completed
and only the one time.

Any help is appreciated.

Alec


Dec 12 '05 #3
Alec,

If you set it in the load_event, than your form is not yet showed. That is
where I set it normally therefore I probably did not understand you.

Cor

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> schreef in bericht
Thanks Cor,

I've tried various approaches to resolving this - including your boolean
suggestion, but as yet nothing works quite how I'd like them to.

It's not an essential aspect, just a small tidying of the visual
presentation when the program loads.

Alec
"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:u9******** ******@TK2MSFTN GP12.phx.gbl...
Alec,

There can be much reasons and always hard to show in a newsgroup (mostly
you need for that to much code), however prevent your listbox from
selecting when you find any data to it.

The beginupdate and endupdate does nothign in that, so you can do that by
setting a boolean when you do that and test that in the events from the
listbox, or just do removehandler and addhandler from those events what
is the nicest.

I hope this helps,

Cor

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> schreef in bericht
news:O0******** ******@TK2MSFTN GP14.phx.gbl...
Hi everyone,

I have a ComboBox that when changed, calls a method to change the
content of a ListBox.
I'm also using the Listbox's SelectedIndexCh anged event to change other
control values on the form.

(It's a Company -> People -> Personal Data relationship)

When I bind my datasource to the ListBox, I find that the
SelectedIndexCh anged event fires three times.
(I am using BeginUpdate / EndUpdate around the databinding statements.)

This multiple event firing causes the side effect of a form-flicker as
the last set of controls get cleared and set.

Is this normal behaviour for the ListBox when using databinding?

I do want the event to fire, but only after the databinding has
completed and only the one time.

Any help is appreciated.

Alec



Dec 12 '05 #4

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

Similar topics

4
11853
by: KK | last post by:
Hi All... For my purpose, I need to handle listbox selection changed event.I must be notified before changing occurs and after.After I can handle using SelectedIndexChanged event.Is there anyway to know which one is selected item before this event.?One thing is I can have a variable to hold the index in my application. I'm looking exactly like TreeView events(which fires events before expanding and after expanding the nodes).
0
5428
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...
6
1338
by: Glen Wolinsky | last post by:
I have two virtually identical listbox controls on a tabPage in my application. I bind a small datatable to each one when a new project (my data) is selected from a treeview control (this works fine). When I select the first project, the data is retrieved without a problem and the datatables are properly bound to both listboxes. The first listbox has a "SelectedIndexChanged" event wired to it which also works fine. Now, here's the...
2
2941
by: Sidney | last post by:
I tried to databind the listbox in vb.net with dataset I wrote some code in the listbox selectedindexchanged event, however, whenever the programme goes to the selectedindexchanged, it hanged and I need to closed the whole system it appear this problem also when i click a check box which the the CheckedChanged event in the check box need refreshing the dataset with another SQL code Thanks a lot~
2
3043
by: Dave A | last post by:
I am stuggling with databinding a drop down list, hooking into the SelectedIndexChanged and attempting to avoid using the viewstate. The drop down list is quite large so I would prefer to avoid using the view state so I set EnableViewState on the page to false. To enable the drop down list to bind to a datasource I bind it during the OnInit. I do a response.Write during the SelectedIndexChanged event to verify that the event fires. ...
0
1281
by: bnolingberg | last post by:
Hi all. I've been stuck on this problem for a while (I'm a newbie). I have a listbox with several collection objects, some of them being identical. When one of the collection items is selected in the listbox, the values of that collection item can be set but if an identical collection item is also present in the listbox, its variables are set as well. I think it has something to do with the SelectedIndexChanged and databinding. I have...
9
3250
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback). This listbox has AutoPostback = True. When the user selects an item from this list, the second listbox is populated with more items relevant to this selection. I am using an SQLDataSource web control for this. These items are headers. I want, when...
2
1455
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= | last post by:
Which is the event sequence when a gridview button (for update) is clicked and the page is post back? I am also a bit confused when to use ..IsPostBack(). If my page data is changing maybe in every 10 or 20 seconds, should I use .IsPostback? If not, then the gridviews databinding in the page should be written in Page_Load or in the other events like SelectedIndexChanged, RowCommand where the click is handled? TIA Iordanis
6
4721
by: Mike | last post by:
Is there a way to get a ListView control to fire its SelectedIndexChanged event like the ListBox control? When the user selects multiple items at once, the ListView fires the event as each item gets selected. The ListBox waits to fire the event until all selections are complete. Thanks, Mike
0
9644
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
10793
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
10509
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
10219
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
9331
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...
1
7757
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6954
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5793
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4427
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

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.