Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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








Reply With Quote
  #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();


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:45 PM.


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