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 pvtRMMListDirec tory;
private string pvtRMMDirectory Info;
public RMMDisplayClass (string strListDirector y, string
strRMMFullDirec tory)
{
this.pvtRMMList Directory = strListDirector y;
this.pvtRMMDire ctoryInfo = strRMMFullDirec tory;
}
public string RMMListDirector y
{
get
{
return pvtRMMListDirec tory;
}
set
{
this.pvtRMMList Directory = value;
}
}
public string RMMFullDirector y
{
get
{
return pvtRMMDirectory Info;
}
set
{
this.pvtRMMDire ctoryInfo = 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 DisplayRMMDirec tories()
{
string lstItem = "";
RMMDirectories. Clear();
string[] RMMDirectoryLis t = myRMMData.GetRM MDataDirectorie s();
foreach (string strRMMDir in RMMDirectoryLis t)
{
try
{
DirectoryInfo di = new DirectoryInfo(s trRMMDir + @"\Forms
Data");
RMMDataTransfer .RMMDataTransfe r.FileDirectory IdInfo idInfo;
idInfo =
RMMDataTransfer .RMMDataTransfe r.GetFileDirect oryIdInfo(di);
rmmTailNumber = idInfo.TailNumb er;
rmmFlightDate = idInfo.TakeoffT ime.ToString("y yyy-MM-dd
HH:mm:ss");
lstItem = rmmTailNumber + " " + rmmFlightDate;
RMMDirectories. Add(new RMMDisplayClass (lstItem, strRMMDir));
di = null;
}
catch (FileNotFoundEx ception exp)
{
//MessageBox.Show (exp.ToString() );
}
catch (Exception exp)
{
Debug.WriteLine (exp.ToString() );
}
}
if (RMMDirectories .Count 0)
{
lstRMMFiles.Dat aSource = RMMDirectories;
lstRMMFiles.Dis playMember = "RMMListDirecto ry";
lstRMMFiles.Val ueMember = "RMMFullDirecto ry";
lstRMMFiles.Ref resh();
}
}
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 1 5309
On Thu, 28 Sep 2006 10:00:02 -0700, WhiteWizard
<Wh*********@di scussions.micro soft.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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 ArrayList only has one element in it everything
works ok. But as soon as I have more than one element, I get the following
exception when the control loads up: "Cannot modify the Items collection
when the DataSource property is set.".
Anybody...
|
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;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
|
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)..
...
|
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 selected items of that listbox and display
it.
can anyone help?
Thanks
|
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 the selected value from the
left listbox. When you select any member from the left listbox and click on
the button to move it to the right listbox, everything works fine. If you
select the LAST member in the left listbox, and click on the button...
| |
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 the array list again to refresh. Click on an item in
the list, and an Indexing error comes up. (in non-user code, it is trying to
get an element from the array that is greater than the number of items in the
array.)
To reproduce:
|
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: 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 entry and you select another index it goes boom!!!.
Funny thing is the SelectedIndex Changed routine fires off perfectly and then crash after the return
from this code.
Now looking around the news groups it appears to be a bug in the .net...
|
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 populating a listbox with an array of very simple "Country" objects via
a WebService. The Country class contains CountryID,TLDs and Name properties
each of which have a getter and setter (I found that properties without
|
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 program use.
But instead of Updating the ListBox, virtually nothing happens. The items that were written into the ListBox during the first run remain inside the ListBox, assuming the new values of the ArrayList. Obviously, if the new ArrayList is...
|
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: 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...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |