473,387 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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



Nov 16 '05 #1
2 2945
Try:
string myItem = myItems.Text;

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

--- HTH, Jeff

"MikeY" wrote:
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



Nov 16 '05 #2
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

"Jeff B." <js*@community.nospam> wrote in message
news:4A**********************************@microsof t.com...
Try:
string myItem = myItems.Text;

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

--- HTH, Jeff

"MikeY" wrote:
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



Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mr. B | last post by:
The following code is how I check for duplicates in a List box. This is simple enough as there is only one column of stuff to check. ' Check for Duplicates ' Search listbox (from last to first)...
0
by: Ben Rush | last post by:
Greetings, I don't deal too much with the visual side of the framework, so I may be simply doing something quite stupid - but if I am I can't figure it out for the life of me. On my machine...
2
by: farmer | last post by:
I need to populate a listbox of other listview with selected listview items.although the following code works perfecty I want to use an Array (for various reasons) for Each ListItem In...
4
by: CR | last post by:
In VB6 if I wanted to display a group of records, and possibly allow the user to select one or more records, I would use the ListBox. For example suppose I wanted to display something like this: ...
1
by: Melson | last post by:
Hi May I know what is the differences between vb.net listbox and listview. When should I use listbox or listview. Regards Melson
1
by: The Confessor | last post by:
I currently have a listbox in my program which I populate with data from a random access file as follows: For T = 1 To HighestPointID FileGet(1, Point(T), T) ListBox_Point.Items.Add(T & " Lat:...
2
by: Tim.Geiges | last post by:
This seems like ti should be very simple but I am sort of a newb and this one is killing me I am just trying to copy all the items that are checked in listView2 over to listView1 when a button is...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
2
by: markliam | last post by:
I have a ListBox that is displaying a formatted string based on the contents of a DataSet. The purpose of the listbox is for the user to select an entry to delete, but I'm not sure how to match...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.