Help 'Check ListView' vs 'Check ListBox'

M

MikeY

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
 
G

Guest

Try:
string myItem = myItems.Text;

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

--- HTH, Jeff
 
M

MikeY

Thank you Jeff. That is exactly what I was looking for but could not find,
doh!!! If I only known that it was in text format.

Thanks again

MikeY
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top