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

Listbox DataSource

First my apologies, this may be longer than the normal question.

I have a windows app (.NET 2.0, VS2005), and I've written a user control
that will allow the user to "drag and drop" a directory from one computer
(files are in NVM), to another (files on a PCMIA memory card). The actual
directory names are meaningless to the user, so we display a data item and a
datetime that the directory was created. When I fill the listbox that is the
target, I create a class that has the "displayed" information and the real
directory name, load instances of those classes into an ArrayList and use
that as the DataSource of the listbox. Here is the code for the class:
public class RMMDisplayClass
{
private string pvtRMMListDirectory;
private string pvtRMMDirectoryInfo;

public RMMDisplayClass(string strListDirectory, string
strRMMFullDirectory)
{
this.pvtRMMListDirectory = strListDirectory;
this.pvtRMMDirectoryInfo = strRMMFullDirectory;
}

public string RMMListDirectory
{
get
{
return pvtRMMListDirectory;
}
set
{
this.pvtRMMListDirectory = value;
}
}

public string RMMFullDirectory
{
get
{
return pvtRMMDirectoryInfo;
}
set
{
this.pvtRMMDirectoryInfo = value;
}
}
}

When I enter the control I have a method that loads all the directories that
are already present on the RMM into an ArrayList, then use that as the
DataSouce for the listbox, and that works fine. HOWEVER, when I do the copy,
it does the copy routine and then I run the same method to "reload" the
listbox to show the copied directory. BUT it does not show up. I clear the
ArrayList, but the copied directory does not appear. If I shut down and
restart it shows up in the list.

I have found a workaround, by setting the DataSource property of the listbox
to null, then clearing the listbox, then resetting the DataSource back to the
ArrayList, but this seems awfully kludgy as they say. Here is the code where
I reset the list box (without workaround).

public void DisplayRMMDirectories()
{
string lstItem = "";
RMMDirectories.Clear();
string[] RMMDirectoryList = myRMMData.GetRMMDataDirectories();
foreach (string strRMMDir in RMMDirectoryList)
{
try
{
DirectoryInfo di = new DirectoryInfo(strRMMDir + @"\Forms
Data");
RMMDataTransfer.RMMDataTransfer.FileDirectoryIdInf o idInfo;
idInfo =
RMMDataTransfer.RMMDataTransfer.GetFileDirectoryId Info(di);
rmmTailNumber = idInfo.TailNumber;
rmmFlightDate = idInfo.TakeoffTime.ToString("yyyy-MM-dd
HH:mm:ss");
lstItem = rmmTailNumber + " " + rmmFlightDate;

RMMDirectories.Add(new RMMDisplayClass(lstItem, strRMMDir));
di = null;
}
catch (FileNotFoundException exp)
{
//MessageBox.Show(exp.ToString());
}
catch (Exception exp)
{
Debug.WriteLine(exp.ToString());
}
}
if (RMMDirectories.Count 0)
{
lstRMMFiles.DataSource = RMMDirectories;
lstRMMFiles.DisplayMember = "RMMListDirectory";
lstRMMFiles.ValueMember = "RMMFullDirectory";
lstRMMFiles.Refresh();
}
}
Anyone got any ideas on why this is working this way, and how to fix other
than my workaround?

TIA
WhiteWizard
aka Gandalf
MCSD.NET, MCAD, MCT
Sep 28 '06 #1
1 5281
On Thu, 28 Sep 2006 10:00:02 -0700, WhiteWizard
<Wh*********@discussions.microsoft.comwrote:

[snip]
>When I enter the control I have a method that loads all the directories that
are already present on the RMM into an ArrayList, then use that as the
DataSouce for the listbox, and that works fine. HOWEVER, when I do the copy,
it does the copy routine and then I run the same method to "reload" the
listbox to show the copied directory. BUT it does not show up. I clear the
ArrayList, but the copied directory does not appear. If I shut down and
restart it shows up in the list.

I have found a workaround, by setting the DataSource property of the listbox
to null, then clearing the listbox, then resetting the DataSource back to the
ArrayList, but this seems awfully kludgy as they say.
[snip]

That's they way I've always done it.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Sep 28 '06 #2

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

Similar topics

4
by: Jason | last post by:
Here is an odd issue. I am trying to shed some light on why this is causing a problem. I have an ArrayList. I am binding it to a ListBox control with has its Sort property set to True. If the...
2
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System;...
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...
5
by: Lie | last post by:
Hi all, I have problem in getting selectedindex of multiple listbox selection in a datagrid. I have a listbox with multiple selection mode inside datagrid. In Edit mode, I need to get back all...
13
by: Larry Woods | last post by:
I am creating a "from-to" set of listboxes where the "left" listbox had a list of values and I want to be able to select these values, 1 at a time, and move them into a "right" listbox, removing...
11
by: Zorpiedoman | last post by:
The problem is this: I have a list box. I set an array list as the datasource. I remove an item from the array list. I set the listbox datasource to nothing. I set the listbox datasource to...
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: John Veldthuis | last post by:
My code works perfectly 100% when adding items to my ArrayList and updating the listbox. Works perfectly when deleting an item in the ArrayList when it is not the last entry but if it is the last...
6
by: Paul | last post by:
Hi All, Framework 1.1 listbox control unable to DataBind I've been googling for an answer to this query that appears quite a lot, but none, it seem, answers my problem directly. I am...
1
by: Refugnic | last post by:
I tried to fill a ListBox with a DataSource pointing to an ArrayList. It all works fine...up to one point. The ArrayList is dynamic, which means the contents of it change, during the course of...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...
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.