Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / February 2005

Tip: Looking for answers? Try searching our database.

Help 'Check ListView' vs 'Check ListBox'

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MikeY - 24 Feb 2005 15:30 GMT
Hi all,

I am coding window forms in C#.

My problem is this: I have created a "Check ListView" or a 'ListView' with
checkbox's. I have populated the it with my files from my folders, mps, txt,
etc. The ListView is in Details, with headers and an Icon.

What I am trying to accomplish is to rename/append check mark file massively
(at once). This is accomplished by the user inputting a name into a provided
textbox 'txtBoxFileConversion' and by the user clicking on the 'convert
button'. The directory/folder is then updated with the new file(s) and so is
the ListView.

I am having problems with my 'convert button' syntax where the data that is
being extracted, the output, comes out like this: ListViewItem:
{webhosting.txt}, instead of the plain: webhosting.txt. Also what format is
the ListView data in? I know with regular CheckListBox's, it is in a string
format.

Now when I use CheckListBox (with basically the same code (string instead of
ListViewItem)), I receive no problems or errors at all, but I do prefer to
use ListView to keep with the order of my other ListViews on the same form,
and because I also want to use the headers, icons, same sizing, etc. Is my
thinking wrong on this? The sample of my button function is below: //Append
(Convert) checkbox selected items with new name:

private void btnConvert_Click(object sender, System.EventArgs e)
{
   { //Test to see if the textbox is blank
       if(this.txtBoxFileConversion.Text != "")
       { //Extract all check-marked items
           foreach(ListViewItem myItems in
this.lvMassFileConversion.CheckedItems)
           {
               string myItem = myItems.ToString();
               string myItem2 = this.txtBoxFileConversion.Text + " - " +
myItems.ToString();
               //Over-write old file with new file
               File.Move(Path.Combine(currentFolderPath, myItems),
Path.Combine(currentFolderPath, myItems2));
           }
       }
       else
       {
           MessageBox.Show("Please enter valid text into the textbox
area");
       }
   }

I've been reading past posts of ListViews, but I don't think anything covers
this topic on ListView. Any and all help, suggestions are truly appreciated.

MikeY
MikeY - 24 Feb 2005 18:18 GMT
I was given a solution to what I was exactly looking for from a gentleman on
another board. It is as follows.

Try:
 string myItem = myItems.Text;

Instead of:
 string myItem = myItems.ToString();

> Hi all,
>
[quoted text clipped - 50 lines]
>
> MikeY

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.