473,740 Members | 10,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListView vs CheckListBox

Hopefully someone can help me on this.

I am using C#, making Windows forms.

I have created a listView with checkbox's. I have enabled the checkboxes
under the properties, and all the data, checkbox's and icons are displayed
as they are meant to be. My problem is this, I am trying to achieve the same
results as I get with CheckListBox(s) , where I am able to select
(Check-mark) various checkboxs items and able to alter the data. I do prefer
to use ListView because of adding icons, view properties, sizing, etc.

A sample of my code is below where I am trying to grab my selected (checked)
items then convert the name with my inputted text name:

foreach(string myItem in this.lvMassFile Conversion.Chec kedItems)
{
string myItem2 = this.txtBoxName Convsersion.Tes t + " - " + myItem;
//Over-write old file with new file

File.Move(Path. Combine(current FolderPath.myIt em).Path.Combin e(currentFolder P
ath.myItme2)
}

Now I can achieve the required results with checklistbox, but because of the
above mentioned I'd like to stay with listview.

Thank you all in advance.

MikeY
Nov 16 '05 #1
3 9307
Hi Mike,

I understand that you are using a list view control with checkboxes besides
each item in the list. But i am unable to get what the exactl problem is. Do
you want the user to be able to edit the items at run time [OR] do you want
to change the contents of the list programatically ?

User editing scenario: The list-view supports in-place editing of its items.
Just set the LabelEdit property to true. Look at
http://msdn.microsoft.com/library/de...ledittopic.asp
for more info.
Programatic updations: You can use the ListView_SetIte mText(iItemNumb er,
iSubItemNumber, blah,blah) macro to set/reset the item and sub-item texts.
To update the item contents, set the iSubItemNumber to zero. Look at
http://msdn.microsoft.com/library/de...etitemtext.asp
for more info.

If this is not what you want, please write back explaining the issue.

Thanks,
Devi J V [MSFT]
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"MikeY" <mi*******@yaho o.c> wrote in message
news:wG******** ***********@new s20.bellglobal. com...
Hopefully someone can help me on this.

I am using C#, making Windows forms.

I have created a listView with checkbox's. I have enabled the checkboxes
under the properties, and all the data, checkbox's and icons are displayed
as they are meant to be. My problem is this, I am trying to achieve the
same
results as I get with CheckListBox(s) , where I am able to select
(Check-mark) various checkboxs items and able to alter the data. I do
prefer
to use ListView because of adding icons, view properties, sizing, etc.

A sample of my code is below where I am trying to grab my selected
(checked)
items then convert the name with my inputted text name:

foreach(string myItem in this.lvMassFile Conversion.Chec kedItems)
{
string myItem2 = this.txtBoxName Convsersion.Tes t + " - " + myItem;
//Over-write old file with new file

File.Move(Path. Combine(current FolderPath.myIt em).Path.Combin e(currentFolder P
ath.myItme2)
}

Now I can achieve the required results with checklistbox, but because of
the
above mentioned I'd like to stay with listview.

Thank you all in advance.

MikeY

Nov 16 '05 #2
Hi Devi,

I was thinking after I posted my question that I might not of gotten the
point across.

My application pulls all my files *.txt, *.mp3, etc from a folder. Where it
is displayed with in my ListView (lvMassFileConv ersion), with checkboxs.
From there the user is able to check-mark the required checkbox's in order
to change their names of the files(append). This happens when the user then
inputs a new name with in a textbox (txtBoxNameConv sersion) and clicks the
conversion button. The checked files then are all renamed (appended). All
the syntax happens with in the Conversion button function. This all takes
place at run-time.

The syntax that I previously posted (but forgot to mention) is the syntax
from when I use the CheckListBox. Now this works just fine (using the
CheckListBox) and I am able to get the exact results that I want, using the
same scenario. But I don't want to use the CheckListBox, because of
previously posted reasons, size, etc. The code I posted was me trying to
modify the syntax to use with my ListView instead, but did not work.

Thanks for the links, but didn't see what I was looking for.

Hopefully I am making more sense over my morning coffee. Any & all help is
appreciated.
MikeY
"Devi JV [MSFT]" <de****@online. microsoft.com> wrote in message
news:ut******** ******@tk2msftn gp13.phx.gbl...
Hi Mike,

I understand that you are using a list view control with checkboxes besides each item in the list. But i am unable to get what the exactl problem is. Do you want the user to be able to edit the items at run time [OR] do you want to change the contents of the list programatically ?

User editing scenario: The list-view supports in-place editing of its items. Just set the LabelEdit property to true. Look at
http://msdn.microsoft.com/library/de...ledittopic.asp for more info.
Programatic updations: You can use the ListView_SetIte mText(iItemNumb er,
iSubItemNumber, blah,blah) macro to set/reset the item and sub-item texts.
To update the item contents, set the iSubItemNumber to zero. Look at
http://msdn.microsoft.com/library/de...etitemtext.asp for more info.

If this is not what you want, please write back explaining the issue.

Thanks,
Devi J V [MSFT]
--
This posting is provided "AS IS" with no warranties, and confers no rights.

"MikeY" <mi*******@yaho o.c> wrote in message
news:wG******** ***********@new s20.bellglobal. com...
Hopefully someone can help me on this.

I am using C#, making Windows forms.

I have created a listView with checkbox's. I have enabled the checkboxes
under the properties, and all the data, checkbox's and icons are displayed as they are meant to be. My problem is this, I am trying to achieve the
same
results as I get with CheckListBox(s) , where I am able to select
(Check-mark) various checkboxs items and able to alter the data. I do
prefer
to use ListView because of adding icons, view properties, sizing, etc.

A sample of my code is below where I am trying to grab my selected
(checked)
items then convert the name with my inputted text name:

foreach(string myItem in this.lvMassFile Conversion.Chec kedItems)
{
string myItem2 = this.txtBoxName Convsersion.Tes t + " - " + myItem;
//Over-write old file with new file

File.Move(Path. Combine(current FolderPath.myIt em).Path.Combin e(currentFolder P ath.myItme2)
}

Now I can achieve the required results with checklistbox, but because of
the
above mentioned I'd like to stay with listview.

Thank you all in advance.

MikeY


Nov 16 '05 #3
Hi Mike,

My apologies for the delayed response. Let me re-state the problem for
better understanding of its solution:

The problem:

The application UI has a List View control and a Text Box and a Button. The
list view displays a list of files with checkboxes besides each file name.
If the user wants to modify the names of certain files, he selects those
files [by checking the corresponding checkboxes] , enters some text in the
text box and then clicks on the button. Now your application should update
all the checked file names with the text in the text box.

The solution:

Let's make certain things clear before i show you the sample code.

1. The ListView.Checke dItems property returns a
CheckedListView ItemCollection.
2. Each object in the collection is a ListViewItem and not a string.
For more info on this see
http://msdn.microsoft.com/library/de...classtopic.asp
3. The filename of [let's say] the first file in the list is the text
property of the first item in the list view. Hence it should be accessed as
ListViewItem.Te xt
For more info on this
http://msdn.microsoft.com/library/de...classtopic.asp

Hence to loop through the items in the collection and update the filename,
you should use something like this:

Sample code:

//get all the checked items in the list
ListView.Checke dListViewItemCo llection checkedItems =
this.lvMassFile Conversion.Chec kedItems;

//for each checked item
foreach ( ListViewItem myItem in checkedItems )
{
//get the new filename
string myFileName = this.txtBoxName Convsersion.Tex t + "-" +
myItem.Text;

// do your file name updation here. Remember, myItem.Text gives you
the filename [myItem given you the entire list view item]
}

To understand more about what a list view control is and how it behaves, you
can look at
http://msdn.microsoft.com/library/de...classtopic.asp
and
http://msdn.microsoft.com/library/de...w_overview.asp
or you can search msdn for a 'listview control'

Thanks,
Devi JV [MSFT]
--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"MikeY" <mi*******@yaho o.c> wrote in message
news:CX******** ***********@new s20.bellglobal. com...
Hi Devi,

I was thinking after I posted my question that I might not of gotten the
point across.

My application pulls all my files *.txt, *.mp3, etc from a folder. Where
it
is displayed with in my ListView (lvMassFileConv ersion), with checkboxs.
From there the user is able to check-mark the required checkbox's in order
to change their names of the files(append). This happens when the user
then
inputs a new name with in a textbox (txtBoxNameConv sersion) and clicks the
conversion button. The checked files then are all renamed (appended). All
the syntax happens with in the Conversion button function. This all takes
place at run-time.

The syntax that I previously posted (but forgot to mention) is the syntax
from when I use the CheckListBox. Now this works just fine (using the
CheckListBox) and I am able to get the exact results that I want, using
the
same scenario. But I don't want to use the CheckListBox, because of
previously posted reasons, size, etc. The code I posted was me trying to
modify the syntax to use with my ListView instead, but did not work.

Thanks for the links, but didn't see what I was looking for.

Hopefully I am making more sense over my morning coffee. Any & all help is
appreciated.
MikeY
"Devi JV [MSFT]" <de****@online. microsoft.com> wrote in message
news:ut******** ******@tk2msftn gp13.phx.gbl...
Hi Mike,

I understand that you are using a list view control with checkboxes

besides
each item in the list. But i am unable to get what the exactl problem is.

Do
you want the user to be able to edit the items at run time [OR] do you

want
to change the contents of the list programatically ?

User editing scenario: The list-view supports in-place editing of its

items.
Just set the LabelEdit property to true. Look at

http://msdn.microsoft.com/library/de...ledittopic.asp
for more info.
Programatic updations: You can use the ListView_SetIte mText(iItemNumb er,
iSubItemNumber, blah,blah) macro to set/reset the item and sub-item
texts.
To update the item contents, set the iSubItemNumber to zero. Look at

http://msdn.microsoft.com/library/de...etitemtext.asp
for more info.

If this is not what you want, please write back explaining the issue.

Thanks,
Devi J V [MSFT]
--
This posting is provided "AS IS" with no warranties, and confers no

rights.


"MikeY" <mi*******@yaho o.c> wrote in message
news:wG******** ***********@new s20.bellglobal. com...
> Hopefully someone can help me on this.
>
> I am using C#, making Windows forms.
>
> I have created a listView with checkbox's. I have enabled the
> checkboxes
> under the properties, and all the data, checkbox's and icons are displayed > as they are meant to be. My problem is this, I am trying to achieve the
> same
> results as I get with CheckListBox(s) , where I am able to select
> (Check-mark) various checkboxs items and able to alter the data. I do
> prefer
> to use ListView because of adding icons, view properties, sizing, etc.
>
> A sample of my code is below where I am trying to grab my selected
> (checked)
> items then convert the name with my inputted text name:
>
> foreach(string myItem in this.lvMassFile Conversion.Chec kedItems)
> {
> string myItem2 = this.txtBoxName Convsersion.Tes t + " - " + myItem;
> //Over-write old file with new file
>
> File.Move(Path. Combine(current FolderPath.myIt em).Path.Combin e(currentFolder P > ath.myItme2)
> }
>
> Now I can achieve the required results with checklistbox, but because
> of
> the
> above mentioned I'd like to stay with listview.
>
> Thank you all in advance.
>
> MikeY
>
>



Nov 16 '05 #4

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

Similar topics

1
3164
by: ncookson | last post by:
I am trying to add a caption or title to the box drawn around a checklistbox and having no luck. Is there a way to do this? I am using python 2.3.4 and wxPython 2.5 on a windows platform. Noel
5
2966
by: Bernie Yaeger | last post by:
Is there any way to get a listbox or a checklistbox behave in an autocomplete manner, such that given 'two', 'three', 'water', 'them' would bring the selection to 'two' (not 'water') when I key in 'tw'? I know using various autocomplete routines I can do this with a combobox, but I need to do it with either a listbox or a checklistbox. Thanks for any help. Bernie Yaeger
2
2965
by: MikeY | last post by:
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
1
7363
by: comic_rage | last post by:
Hi, I created a checkListBox to allow the user to select and place a check next to multiple items in the GUI. I would like to add a 2 column where the first column show the description of the item and the second column show the version. How can I create 2 columns with a checkListBox? How can I add a header above the 2 columns to show item | version?
2
16675
by: Mike Kim | last post by:
hi all, i have a checklistbox populated with about 50 items from database. and on the same form, i added to button to do the following. if you click this button, i want to have all items in the checklistbox to be checked i want to have all items in the checklistbox to be unchecked. thanks advance, folks.
0
3118
by: Ville Mattila | last post by:
Dear readers, I've some problems with the data binding of the checklistbox control. I'm using it with user preferences that are stored in a XML File. Information from the file is fetched with SelectSingleNode and XPath. The checklistbox list values and display texts are loaded from a datatable. I've managed to do that with the DataSource, DisplayMember and ValueMember. No problems with that.
1
1937
by: obrienkev | last post by:
Hi, I want to mark the CheckListBox items as Checked based on a database query. So the CheckListBox items should be checked if each item matches fundsAffected field from the below query... SELECT DISTINCT fundsAffected as myFunds FROM myFunds AS f INNER JOIN myDetails AS d ON d.corpID = f.corpID WHERE d.securityID = securityID
3
1532
by: obrienkev | last post by:
Hi all, How do I mark an item in a checklistbox as checked based on a condition? e.g. if(x=1) { // SET a ChecklistBox Item as Checked }
3
3388
by: khalidjan9 | last post by:
I have data in an arraylist and i want to add data to checklist box on runtime and i also want to display a textbox besides it so that i get the comments example : checklistbox "text" textbox checklistbox "text" textbox checklistbox "text" textbox checklistbox "text" textbox checklistbox "text" textbox can any 1 pleeez help... tks in adv.. :)
0
8969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8794
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9272
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9211
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6756
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6056
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4826
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2195
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.