473,624 Members | 2,543 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 7752
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
11839
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
5415
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
1328
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
2938
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
3021
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
1273
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
3214
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
1440
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
4715
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
8179
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
8685
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...
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7176
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
5570
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
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.