.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

how to select all Check Box

Posted By: kamlesh     Posted Date: May 31, 2011    Points:5   Category :C#
Hi
i have one list box and button.
on list box i get list of users with checkbox suppose in that list box their are 100 users so i want to select all 100 user on button click how it is possible in c#
please help me...

Responses
Author: Dhiraj Ranka             
Posted Date: May 31, 2011     Points: 20   

Hi,

You can have some code like this,


for(int i=0;i<ListBox1.Items.Count;i++)
{
ListBox1.Items[i].Selected = true;
}


Hope this helps

Hope this helps.

Thanks & Regards,
Dhiraj Ranka
http://www.twitter.com/dhirajranka | http://www.dhirajranka.com
Author: Ravi Ranjan Kumar             
Posted Date: June 04, 2011     Points: 20   

Its seems that you are using CheckedListBox if so then use given function to check the Items in your Listbox
 public void Check(CheckedListBox obj, int min, int max)
{
for (int i = min; i <= max; i++)
{
obj.SetItemChecked(i, true);
}
}

on click event of button you can use given code as
private void button1_Click(object sender, EventArgs e)
{
Check(checkedListBox1,0,100);
}


Try it :)

Thanks & Regards
Ravi Ranjan Kumar
http://raviranjankr.wordpress.com
Author: shiv chandra             
Posted Date: June 07, 2011     Points: 20   

Checkout this link.

http://www.codeproject.com/KB/webforms/SelectingAllCheckBoxes.aspx


------
Shiva


Regards
Shiva


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend