Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
| Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 24th, 2005, 12:11 PM
Registered User
 
Join Date: Apr 2004
Location: Toronto, Ont, Canada.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help 'Check ListView' vs 'Check ListBox'

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








  #2 (permalink)  
Old February 24th, 2005, 02:20 PM
Registered User
 
Join Date: Apr 2004
Location: Toronto, Ont, Canada.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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();




Similar Threads
Thread Thread Starter Forum Replies Last Post
How to check programmatically check the password? thomaskelly ASP.NET 1.0 and 1.1 Basics 1 May 16th, 2008 08:49 PM
Connect to VSS check-in Check-out Programatically rhd110 General .NET 6 August 12th, 2007 07:46 AM
Check In /Out Nerd_I_Be General .NET 1 May 8th, 2007 04:56 AM
Check In / Check Out Nerd_I_Be SQL Server 2005 1 May 7th, 2007 01:15 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.