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

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.SelectedItem

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 1410
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***@discussions.microsoft.com> 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.SelectedItem

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.SelectedItem

permit = drv("ID_CUTTING_PERMIT")
_datasetAmend.Clear()

lstAmendments.DataSource = Nothing

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

_dataviewAmend = New DataView(_datasetAmend
..Tables("vwCuttingPermitAmendApp"), "", "STR_AMEND_NO",
DataViewRowState.CurrentRows)

Me.lstAmendments.DataSource = _dataviewAmend
lstAmendments.DisplayMember = "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(_datasetAmend
.Tables("vwCuttingPermitAmendApp"), "", "STR_AMEND_NO",
DataViewRowState.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.public.dotnet.framework.adonet

or the VB newsgroups

microsoft.public.dotnet.languages.vb
microsoft.public.dotnet.languages.vb.data

On Sat, 23 Jul 2005 23:09:02 +0200, amber <am***@discussions.microsoft.com> 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.SelectedItem

permit = drv("ID_CUTTING_PERMIT")
_datasetAmend.Clear()

lstAmendments.DataSource = Nothing

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

_dataviewAmend = New DataView(_datasetAmend
.Tables("vwCuttingPermitAmendApp"), "", "STR_AMEND_NO",
DataViewRowState.CurrentRows)

Me.lstAmendments.DataSource = _dataviewAmend
lstAmendments.DisplayMember = "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
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
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)...
6
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...
7
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...
5
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...
5
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...
3
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
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...
6
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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...

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.