473,394 Members | 1,674 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,394 software developers and data experts.

CheckListBox.checked

MSN
xp pro/vs 2002/web forms/VB

How do I make a checkbox checked when add it to a checkboxlist.

Thanks
Nov 20 '05 #1
16 4611
* "MSN" <To************@msn.com> scripsit:
How do I make a checkbox checked when add it to a checkboxlist.


\\\
Me.CheckedListBox.Items.Add("Foo", True)
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Errata:

Sorry, I missed the "web forms" for some reason...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi MSN,

You can use the designer and than the collections and set selected to true,

Or you can do it in code than it is
\\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Me.CheckBoxList1.Items(0).Selected = True
End Sub
///
OR
In the aspx html page
\\\
<asp:CheckBoxList id="CheckBoxList1" style="Z-INDEX: 102; LEFT: 416px;
POSITION: absolute; TOP: 304px"
runat="server" Width="163px">
<asp:ListItem Value="Eerste" Selected="True">Eerste</asp:ListItem>
</asp:CheckBoxList>
///

I hope this helps?

Cor
Nov 20 '05 #4
> Sorry, I missed the "web forms" for some reason...

I missed it as well, I am suprissed you saw it.
(I made the in my idea correct answer)

:-)

Cor
Nov 20 '05 #5
MSN,
Have you tried something like:

Dim item As New ListItem("apples")
item.Selected = True
CheckBoxList1.Items.Add(item)

Hope this helps
Jay

"MSN" <To************@msn.com> wrote in message
news:uk**************@TK2MSFTNGP09.phx.gbl...
xp pro/vs 2002/web forms/VB

How do I make a checkbox checked when add it to a checkboxlist.

Thanks

Nov 20 '05 #6
Hi Jay,

Look at the post from Herfried, therefore I made some extra work to correct
it.
(If Herfried is right, and in this case I assume that)

Cor
Nov 20 '05 #7
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Look at the post from Herfried, therefore I made some extra work to correct
it.


I still don't understand why Jay's solution should be wrong...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #8
Hi,
Look at the post from Herfried, therefore I made some extra work to correct it.


I still don't understand why Jay's solution should be wrong...


Did I say that Herfried?

However that kind of answers you see not do me.

You are right.

Stuppid me.

Cor
Nov 20 '05 #9
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Look at the post from Herfried, therefore I made some extra work to correct it.


I still don't understand why Jay's solution should be wrong...


Did I say that Herfried?


Sounded like that, but EOT ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #10
Hi Herfried,
I still don't understand why Jay's solution should be wrong...

Did I say that Herfried?


Sounded like that, but EOT ;-).

Not with that quoting, looks if I reals sayd that now.

I have once said that before when you quote you have to do that right.

You constructed now a negative message from me by deleting text, I know
another one who is very good in it.

That is the reason why I prefer Top quoting by the way.

Cor
Nov 20 '05 #11
MSN

Thanks for all the help so far

I tried this, it adds to the checklistbox the text and value but not
checked.

Dim NewItem as New ListItem
NewItem.Selected = True
NewItem.Text = drdReader!Product
NewItem.Value = drdReader!ProductID
chklstProducts.Items.Add(NewItem)

I have a list that I take from a database of products to create the
selections.
But when someone selects a record to edit I populate textboxes and I want to
check the selections that were stored in the database for that customer.

Thanks


"MSN" <To************@msn.com> wrote in message
news:uk**************@TK2MSFTNGP09.phx.gbl...
xp pro/vs 2002/web forms/VB

How do I make a checkbox checked when add it to a checkboxlist.

Thanks

Nov 20 '05 #12
Cor,
Huh?

What post from Herfried? The only post from Herfried (as well as you) in
this thread is about using the Windows Forms CheckBoxList?

Remember this is about the Web Forms!

I will look at MSN's second post and follow up.

Thanks
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Oj**************@TK2MSFTNGP12.phx.gbl...
Hi Jay,

Look at the post from Herfried, therefore I made some extra work to correct it.
(If Herfried is right, and in this case I assume that)

Cor

Nov 20 '05 #13
MSN,
The following works in VS.NET 2003.

Dim item As ListItem

item = New ListItem
item.Selected = True
item.Text = "Product1"
item.Value = "1"
CheckBoxList1.Items.Add(item)

item = New ListItem
item.Selected = False
item.Text = "Product2"
item.Value = "2"
CheckBoxList1.Items.Add(item)

item = New ListItem
item.Selected = True
item.Text = "Product3"
item.Value = "3"
CheckBoxList1.Items.Add(item)

The first & third item will be checked, the second will not.

Hope this helps
Jay

"MSN" <To************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Thanks for all the help so far

I tried this, it adds to the checklistbox the text and value but not
checked.

Dim NewItem as New ListItem
NewItem.Selected = True
NewItem.Text = drdReader!Product
NewItem.Value = drdReader!ProductID
chklstProducts.Items.Add(NewItem)

I have a list that I take from a database of products to create the
selections.
But when someone selects a record to edit I populate textboxes and I want to check the selections that were stored in the database for that customer.

Thanks


"MSN" <To************@msn.com> wrote in message
news:uk**************@TK2MSFTNGP09.phx.gbl...
xp pro/vs 2002/web forms/VB

How do I make a checkbox checked when add it to a checkboxlist.

Thanks


Nov 20 '05 #14
MSN
thank you

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:eg**************@TK2MSFTNGP12.phx.gbl...
MSN,
The following works in VS.NET 2003.

Dim item As ListItem

item = New ListItem
item.Selected = True
item.Text = "Product1"
item.Value = "1"
CheckBoxList1.Items.Add(item)

item = New ListItem
item.Selected = False
item.Text = "Product2"
item.Value = "2"
CheckBoxList1.Items.Add(item)

item = New ListItem
item.Selected = True
item.Text = "Product3"
item.Value = "3"
CheckBoxList1.Items.Add(item)

The first & third item will be checked, the second will not.

Hope this helps
Jay

"MSN" <To************@msn.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...

Thanks for all the help so far

I tried this, it adds to the checklistbox the text and value but not
checked.

Dim NewItem as New ListItem
NewItem.Selected = True
NewItem.Text = drdReader!Product
NewItem.Value = drdReader!ProductID
chklstProducts.Items.Add(NewItem)

I have a list that I take from a database of products to create the
selections.
But when someone selects a record to edit I populate textboxes and I
want to
check the selections that were stored in the database for that customer.

Thanks


"MSN" <To************@msn.com> wrote in message
news:uk**************@TK2MSFTNGP09.phx.gbl...
xp pro/vs 2002/web forms/VB

How do I make a checkbox checked when add it to a checkboxlist.

Thanks



Nov 20 '05 #15
Hi Jay,

No mine is as well for the webform, I did give it for using the designer,
using vb code and using direct ASP/HTML, however forget it, I did read your
message wrong while it is very well alternative on the methode I showed.

Was my mistake reading your post,

Sorry

Cor
What post from Herfried? The only post from Herfried (as well as you) in
this thread is about using the Windows Forms CheckBoxList? Remember this is about the Web Forms! I will look at MSN's second post and follow up.


Nov 20 '05 #16
Cor,
Doh! It would appear that we both read messages wrong in this thread!

As you now realize my original message added to your message without taking
anything away.

Your comments to Herfried, then your continued comments to me, lead me to
believe you inadvertently gave a Winform answer instead of a Webform answer.
I'm not sure if Herfried's answer really counts either way as I get a
compile error on VS.NET 2003 with it, however CheckBoxList is a web control.
Herfried's fails with: "Overload resolution failed because no accessible
'Add' accepts this number of arguments"

Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eU**************@TK2MSFTNGP11.phx.gbl...
Hi Jay,

No mine is as well for the webform, I did give it for using the designer,
using vb code and using direct ASP/HTML, however forget it, I did read your message wrong while it is very well alternative on the methode I showed.

Was my mistake reading your post,

Sorry

Cor
What post from Herfried? The only post from Herfried (as well as you) in
this thread is about using the Windows Forms CheckBoxList?

Remember this is about the Web Forms!

I will look at MSN's second post and follow up.


Nov 20 '05 #17

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

Similar topics

3
by: john sutor | last post by:
Does anyone know how to get the index of an item checked and then check it if it is unchecked?
3
by: MikeY | last post by:
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,...
1
by: satankidneypie | last post by:
Hi, has anyone implemented a checkedlistbox with images as well as text, and if so can I have some sample code please?! Thanks, Stu
0
by: D. Shane Fowlkes | last post by:
I have a form with a CheckBoxList which is created from a SQLDataReader. It contains Staff personnel and I use the ID and LogOnName (a string) to build the CBL. All works fine. I also have a...
2
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...
2
by: cos75 | last post by:
When I populate a checklistbox with Add method every item is showed equal to the others I would show some item enabled, and some disabled......some item in black text and others in red text Is...
0
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...
1
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... ...
3
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...
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:
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...
0
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...
0
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...

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.