Hi all,
I have a listbox that is complex bound by an arraylist. The problem is that
when I delete an object from the arraylist, the listbox does not reflect
those changes. I tried refreshing the listbox with no luck and, because it
is already bound, I can't just delete the item directly from the listbox
without an error (because it already has a datasource, you are not allowed
to delete/add anything to the listbox directly).
The application basically is doing nothing but a dual listbox populator
(values in the right listbox are sent to the left with an "add" or an "add
all" button - and vice-versa with "remove" and "Remove all"). Instead of
using datatables, it uses arraylists to keep track of objects. Because the
objects will ultimately contain more than 1 item, I can't do a simple
binding (I wish MS did not ruin the listbox).
If anyone has seen a dual listbox using arraylists (instead of datatables),
please post a link or code .
Private alRegionNames As New ArrayList
Private alSelectedRegio nNames As New ArrayList
Private Sub form4_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
loadDBRegionNam es()
End Sub
Private Sub loadDBRegionNam es()
alRegionNames = SalesRegionsDB. GetRegionNamesA ctiveAL 'returns an
arraylist of SalesRegionDD objects
lstRegionNames. DisplayMember = "reg_name"
lstRegionNames. ValueMember = "reg_idx"
lstRegionNames. DataSource = alRegionNames 'this listbox is bound to the
arraylist, so changes to the arraylist should reflect in the listbox, but
they do not!
lstSelectedRegi onNames.Display Member = "reg_name"
lstSelectedRegi onNames.ValueMe mber = "reg_idx"
End Sub
Private Sub Add() 'moves items from the right listbox to the left listbox
If lstRegionNames. SelectedIndex < 0 Then Return
Dim sr As New SalesRegionDD
sr = lstRegionNames. SelectedItem
Me.lstSelectedR egionNames.Item s.Add(sr)
Me.TextBox1.Tex t = sr.reg_idx
Me.alRegionName s.Remove(sr)
End Sub
Private Sub btnAdd_Click(By Val sender As System.Object, ByVal e As
System.EventArg s) Handles btnAdd.Click
Me.Add()
End Sub
Here is the SalesRegionDD class (DD stands for dropdown in case you were
wondering - this is reused in other parts of the app for dropdowns):
Public Class SalesRegionDD
Private _reg_idx As String
Private _reg_name As String
Public Sub New() 'nothing happens here, yet
End Sub
Public Property reg_idx() As String
Get
Return _reg_idx
End Get
Set(ByVal Value As String)
_reg_idx = Value
End Set
End Property
Public Property reg_name() As String
Get
Return _reg_name
End Get
Set(ByVal Value As String)
_reg_name = Value
End Set
End Property
End Class
If anyone has any insight on what I am doing wrong or if this is another MS
DotNet bug I am wasting my time chasing, please let me know. I've spent an
entire week trying to do a simple ping-pong dual listbox (driven by a
database) bound by arraylists.
A dual listbox is such a common item in DB apps, I can't believe that no one
has done one before in VB.Net (I spent an afternoon at the bookstore
looking for an example with no luck).
Help!
TIA
Dave 0 1682 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vipin Kedia |
last post by:
Hi
I have written a code for showing the list boxes as selected using a
Listitem and the selected property of the items.
Now I have 2 list boxes in my page. But it shows only the selected values
of the last list box in both the list boxes.
If i reverse the calls to the filllistbox methods it shows the value
selected for the 1st list box in both the listboxes.
I have the code for my method below. Is there a way I can solve this
problem?
|
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:
|
by: Gittyup |
last post by:
Help please,
We have a form, based on a query, that contains a listbox. The contents of
the listbox are based on the results of the query.
When the form is opened, the user selects an item from the listbox, and,
using the AfterUpdate and Visible properties, a subform appears with
information relative to the selected item.
It works perfectly.
|
by: Luca |
last post by:
Hello,
I'm using a windows form in which there is a standard ListBox control. I
want to add/remove objects from the ArrayList associated to the ListBox, and
I want the ListBox immediately shows graphically the change: e.g. if I
remove an element from the ArrayList object, then that element should not be
no more displayed in the list box.
Actually i'm using this code below:
|
by: Matthew Woods |
last post by:
Hi, is there any way to format and order the columns displayed in a datagrid
bound to a class that inherits from IBindingList? i have used
DataGridTableStyle and added DataGridTextBoxColumns to it in the correct
order which works fine if the dataGrid.dataSource = "ArrayList", but it
doesn't work for my IBindingList wrapper.
If i bind the datasource to the arraylist method then the
ListChangedEventHandler is never invoked and my grid only...
| |
by: Clark Stevens |
last post by:
I have an ArrayList (CAL) bound to a listbox (Listbox1). I want to delete
an item in the ArrayList and reflect the changes back to the listbox. I
have no problem deleting ArrayList items, but how do I get the listbox to
reflect the deleted items? Here's what I have so far which doesn't work.
What am I doing wrong?
Private Sub mnuDelete_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles mnuDelete.Click
If...
|
by: Dave Sauny |
last post by:
Ok, its a friday, I'm at work and I cant get this to work:
I have 3 listboxes on one tab control page. when i select an item in
listbox1 i want whatever is selected on the other 2 listboxes
unselected. when listbox2 is selected, 1 and 3 should have no items
selected and the same with listbox 3.
Sounds simple... should be simple! I have tried
listbox.clearselected(), listbox.selectedindex=-1 and beating it
with a large stick. But so...
|
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:
|
by: rn5a |
last post by:
Can the items in a ListBox be sorted by the name of the items?
The ListBox actually lists all directories & files existing in a
directory on the server. Note that all the directories should be listed
first followed by the files.
|
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...
|
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,...
| |
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...
|
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...
|
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,...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |