Click here to Skip to main content
11,704,472 members (50,410 online)
Click here to Skip to main content

CheckComboBox for ASPX web

, 3 Jan 2007 CPOL 26.6K 182 17
Rate this:
Please Sign up or sign in to vote.
CheckComboBox for ASPX Web

Sample Image - CheckComboBox_for_web.jpg

How to use

It is very easy to use. Just follow the steps given below:

  1. Provide a DataTable, which has the first column named "Text" and the second column named "Value", as its DataSource
  2. Set its checked items by setting the value string of its "SelectedValue" property, and the value string is divided by comma
  3. Right click to select all or none, so do the first checkbox without text in dropdownlist
  4. Click to hide all expanded menu, except for the one on which the cursor is

The three required files are:

  1. CheckComboBox.ascx.cs
  2. CheckComboBox.ascx
  3. Yan.js

The sample code is given below:

// set its DataSource and Binding.
DataTable dt0 = new DataTable();

dt0.Columns.Add("Text", System.Type.GetType("System.String"));
dt0.Columns.Add("Value", System.Type.GetType("System.String"));

for (int i = 0; i < 100; i++)
{
  DataRow dr = dt0.NewRow();

  dr[1] = i.ToString();
  dr[0] = ((char)('A' + i)).ToString();

  dt0.Rows.Add(dr);
}

CheckComboBox1.DataSrc = dt0;


// get its selected values
Response.Write("
Control 1
Checked Value=" + CheckComboBox1.SelectedValue);

// set its selected items
CheckComboBox1.SelectedValue = "1,11,111";

// clear its selected items
CheckComboBox1.SelectedValue = "";

// if you want to hide all expanded menu of CheckComboBox by click,
// you must provide all id of CheckComboBox in the page
// and invoke the HideAllMenu() JavaScript method, as the following HTML code.
...
<body onclick="HideMenu()">
...
</body>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Runming Yan
Software Developer (Senior)
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralH, you must be a Chinese programmer Pin
Lawson.Xiang3-Sep-09 22:29
memberLawson.Xiang3-Sep-09 22:29 
GeneralHi Pin
mbaocha6-May-09 17:33
membermbaocha6-May-09 17:33 
GeneralNot function in Firefox Pin
psuporte26-Jun-08 3:00
memberpsuporte26-Jun-08 3:00 
QuestionThanks, are you a Chinese? Pin
Webdiyer8-Jan-07 19:49
memberWebdiyer8-Jan-07 19:49 
AnswerRe: Thanks, are you a Chinese? Pin
Runming Yan9-Jan-07 14:26
memberRunming Yan9-Jan-07 14:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 4 Jan 2007
Article Copyright 2007 by Runming Yan
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid