473,698 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Listbox oddity

I'm having some trouble with a listbox on a Windows form.

Initially it populates fine. I have another listbox (listbox1) and when it's
index changes, listbox2 is repopulated.
I have a textbox that displays what is selected in listbox2.
It is rare that listbox2 has any data right now.
So if I click through listbox1, and there is no data to put in listbox2,
it's fine.
When I click on the first item in listbox1 that does have data to display in
listbox2, it's fine.
Then, when I move to another item in listbox1, my listbox2 never changes.
Whatever was displayed in there the 1st time, remains.
The wierd thing is, the textbox, that is populated with the code:

dim drv as datarowview
drv = Me.listbox2.Sel ectedItem

Me.txtbox1.Text = drv("STR_AMEND_ NO").ToString

this displays the correct data...
and if there are supposed to be greater than 1 items in listbox2, but only 1
is displaying (from a previous selection), i can still click on 1 or 2 items
in listbox2 (even though I can't see them) and the correct data displays in
txtbox1.

I'm not sure if I've given enough information to go on here...but I'm very
frustrated!!

TIA!
Amber

Jul 22 '05 #1
5 1423
Amber,

For a listbox is at least important how you populate it.

Can you tell us that for both?

Cor
Jul 23 '05 #2
Hi Amber,

It seems to be that you are forgetting to clear the data in listBox2 when the item in listBox1 change, but as Cor said, please tell us how you populate your ListBoxes (code sample).
On Sat, 23 Jul 2005 00:45:01 +0200, amber <am***@discussi ons.microsoft.c om> wrote:
I'm having some trouble with a listbox on a Windows form.

Initially it populates fine. I have another listbox (listbox1) and when it's
index changes, listbox2 is repopulated.
I have a textbox that displays what is selected in listbox2.
It is rare that listbox2 has any data right now.
So if I click through listbox1, and there is no data to put in listbox2,
it's fine.
When I click on the first item in listbox1 that does have data to display in
listbox2, it's fine.
Then, when I move to another item in listbox1, my listbox2 never changes.
Whatever was displayed in there the 1st time, remains.
The wierd thing is, the textbox, that is populated with the code:
dim drv as datarowview
drv = Me.listbox2.Sel ectedItem

Me.txtbox1.Text = drv("STR_AMEND_ NO").ToString

this displays the correct data...
and if there are supposed to be greater than 1 items in listbox2, but only 1
is displaying (from a previous selection), i can still click on 1 or 2 items
in listbox2 (even though I can't see them) and the correct data displays in
txtbox1.

I'm not sure if I've given enough information to go on here...but I'm very
frustrated!!

TIA!
Amber


--
Happy coding!
Morten Wennevik [C# MVP]
Jul 23 '05 #3
What code would I use to clear my listbox?

I populate my listboxes as follows.
lboxCP = listbox1 in my previous post
lstAmendments= listbox 2

this sub is called whenever the index of listbox1 (lBoxCP) is changed:

Private Sub getCPAmends()

Dim permit As String
Dim drv As DataRowView

drv = lBoxCP.Selected Item

permit = drv("ID_CUTTING _PERMIT")
_datasetAmend.C lear()

lstAmendments.D ataSource = Nothing

_datasetAmend = _opmanager.getC PAmend(permit)
** note that here I call a function that uses MS Application Blocks add-in
to populate my dataset **

_dataviewAmend = New DataView(_datas etAmend
..Tables("vwCut tingPermitAmend App"), "", "STR_AMEND_ NO",
DataViewRowStat e.CurrentRows)

Me.lstAmendment s.DataSource = _dataviewAmend
lstAmendments.D isplayMember = "STR_AMEND_ NO"

Is this enough information??
TIA!
Amber

Jul 23 '05 #4
Amber,

Why not try what happens when you set this statement not in one line in its
constructor, however one by one by setting the properties. I think that it
makes your problem more clear
_dataviewAmend = New DataView(_datas etAmend
.Tables("vwCutt ingPermitAmendA pp"), "", "STR_AMEND_ NO",
DataViewRowStat e.CurrentRows)

Just my thought,

Cor
Jul 24 '05 #5
Hi amber,

I'm afraid I'm not sure what happens although I think I have heard of something similar before (at least regarding being able to select invisible items).

If you are running McAffee antivirus it might be worth trying to update it.

If the code is called by windows in an event it may also be that an exception is swallowed. Put the code inside a try catch block.

Since the question is related to databases/datasources you might want to try this newsgroup

microsoft.publi c.dotnet.framew ork.adonet

or the VB newsgroups

microsoft.publi c.dotnet.langua ges.vb
microsoft.publi c.dotnet.langua ges.vb.data

On Sat, 23 Jul 2005 23:09:02 +0200, amber <am***@discussi ons.microsoft.c om> wrote:
What code would I use to clear my listbox?

I populate my listboxes as follows.
lboxCP = listbox1 in my previous post
lstAmendments= listbox 2

this sub is called whenever the index of listbox1 (lBoxCP) is changed:

Private Sub getCPAmends()

Dim permit As String
Dim drv As DataRowView

drv = lBoxCP.Selected Item

permit = drv("ID_CUTTING _PERMIT")
_datasetAmend.C lear()

lstAmendments.D ataSource = Nothing

_datasetAmend = _opmanager.getC PAmend(permit)
** note that here I call a function that uses MS Application Blocks add-in
to populate my dataset **

_dataviewAmend = New DataView(_datas etAmend
.Tables("vwCutt ingPermitAmendA pp"), "", "STR_AMEND_ NO",
DataViewRowStat e.CurrentRows)

Me.lstAmendment s.DataSource = _dataviewAmend
lstAmendments.D isplayMember = "STR_AMEND_ NO"

Is this enough information??
TIA!
Amber


--
Happy coding!
Morten Wennevik [C# MVP]
Jul 24 '05 #6

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

Similar topics

12
2399
by: Michael Foord | last post by:
Here's a little oddity with 'print' being a reserved word... >>> class thing: pass >>> something = thing() >>> something.print = 3 SyntaxError: invalid syntax >>> print something.__dict__ {}
17
3118
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP) Me.lboxRP.SetSelected(newRPindex, True) When the last line executes, I get an error message:
6
2874
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset a denormalized mirror of the database, but I'm not having much luck getting the selection logic down (I haven't found a 'hook' where I can access the listbox object as an object to set the listitem's selected property before it gets rendered).. ...
7
4531
by: Dave | last post by:
Hi all, After unsuccessfully trying to make my own dual listbox control out of arraylists, I decided to look for a 3rd party control. I've looked for over a week now and can't find anything but ASP.Net stuff when I need a Windows Form control. I've seen dual listbox populators in countless Windows applications, and have seen them run very fast, so I figured this would be extremely popular. Here's how it should work:
5
222
by: amber | last post by:
I'm having some trouble with a listbox on a Windows form. Initially it populates fine. I have another listbox (listbox1) and when it's index changes, listbox2 is repopulated. I have a textbox that displays what is selected in listbox2. It is rare that listbox2 has any data right now. So if I click through listbox1, and there is no data to put in listbox2, it's fine. When I click on the first item in listbox1 that does have data to...
5
1786
by: jmdocherty | last post by:
All, I've been trying to set up a CSS layout and all seems well in Firefox but in Safari it just seems to be plain weird! I hope someone can help tell me whether this is a problem with my code or a Safari oddity (which if it is, any top-tips to fix it would be most welcome!). Objective: I want to have the meat of the viewport divided into 3 columns (a fixed margin (say 140px) and 2 scalable panes on the right each of which
3
2293
by: Ali Chambers | last post by:
Hi, I have created a listbox called "dtlist1" on my VB.NET form. I call a procedure as follows: Private Sub openfile(flname As String) dtlist1.Items.Clear() etc..
43
2719
by: michael.f.ellis | last post by:
The following script puzzles me. It creates two nested lists that compare identically. After identical element assignments, the lists are different. In one case, a single element is replaced. In the other, an entire column is replaced. --------------------------------------------------------------------------------------- ''' An oddity in the behavior of lists of lists. Occurs under Python 2.4.3 (#69, Mar 29 2006, 17:35:34)
6
1086
by: Rex the Strange | last post by:
Hello all, Traditionally I'm a Delphi and VB6 programmer and have recently started working with VB.NET (which, I might add, I love, but that's beside the point). Anyway, I was trying to make a catch-all library of routines which I use commonly (I have one in Delphi and I was porting some of the routines to VB.NET). I was delighted to find out about modules - I love that a language doesn't tie you to making everything an object - in my...
0
8608
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
9164
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
8898
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
8870
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...
1
6524
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
4370
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2006
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.