473,728 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Checked Combo Box.

Can anyone help me about how to create combo box with its items as
checked boxes or radio buttons. This has to be done in C#.
I have seen something similar to this named custom combo boxes but they
are in MFC I have to remain constrained only in C#.

Jan 12 '07 #1
3 22538
Hi,
There is a CheckedListBox included in the c# ToolBox you could use.

If that isn't quite what you are looking for then you could consider
making a usercontrol with a normal combo and a CheckedListBox . If you
override the dropdown event, you could display the CheckedListBox
instead of the normal dropdown list.

HTH,
James Randle.

saurabhnsit2... @gmail.com wrote:
Can anyone help me about how to create combo box with its items as
checked boxes or radio buttons. This has to be done in C#.
I have seen something similar to this named custom combo boxes but they
are in MFC I have to remain constrained only in C#.
Jan 12 '07 #2
Hi,
can you elaborate bit more on it. Because I have alraedy added some
code regarding that to dropdown event as follows:-

this.comboBox1. Items.Add(check edListBox1);

It is just for testing whether it is added or not. It seems that
something is adding but its not displaying any checked list in drop
down list.

pigeonrandle wrote:
Hi,
There is a CheckedListBox included in the c# ToolBox you could use.

If that isn't quite what you are looking for then you could consider
making a usercontrol with a normal combo and a CheckedListBox . If you
override the dropdown event, you could display the CheckedListBox
instead of the normal dropdown list.

HTH,
James Randle.

saurabhnsit2... @gmail.com wrote:
Can anyone help me about how to create combo box with its items as
checked boxes or radio buttons. This has to be done in C#.
I have seen something similar to this named custom combo boxes but they
are in MFC I have to remain constrained only in C#.
Jan 12 '07 #3
Hi,
Apologies for the slow reply.

You didn't quite understand what i meant.

Add a new UserControl into your project called 'CheckedDropDow n' and
paste the code below over the stuff that is automatically created.

//START of code

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Drawing;
using System.Data;
using System.Windows. Forms;

namespace WinAppSQLTestAp ps
{
/// <summary>
/// Summary description for CheckedDropDown .
/// </summary>
public class CheckedDropDown : System.Windows. Forms.UserContr ol
{
private System.Windows. Forms.ComboBox comboBox1;
private System.Windows. Forms.CheckedLi stBox checkedListBox1 ;
/// <summary>
/// Required designer variable.
/// </summary>
private System.Componen tModel.Containe r components = null;

public CheckedDropDown ()
{
// This call is required by the Windows.Forms Form Designer.
InitializeCompo nent();

// TODO: Add any initialization after the InitializeCompo nent call

}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}

#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.comboBox1 = new System.Windows. Forms.ComboBox( );
this.checkedLis tBox1 = new System.Windows. Forms.CheckedLi stBox();
this.SuspendLay out();
//
// comboBox1
//
this.comboBox1. Dock = System.Windows. Forms.DockStyle .Top;
this.comboBox1. DropDownStyle =
System.Windows. Forms.ComboBoxS tyle.DropDownLi st;
this.comboBox1. Location = new System.Drawing. Point(0, 0);
this.comboBox1. MaxDropDownItem s = 1;
this.comboBox1. Name = "comboBox1" ;
this.comboBox1. Size = new System.Drawing. Size(150, 21);
this.comboBox1. TabIndex = 0;
this.comboBox1. DropDown += new
System.EventHan dler(this.combo Box1_DropDown);
//
// checkedListBox1
//
this.checkedLis tBox1.Dock = System.Windows. Forms.DockStyle .Fill;
this.checkedLis tBox1.Items.Add Range(new object[] {
"Item 1",
"Item 2",
"Item 3"});
this.checkedLis tBox1.Location = new System.Drawing. Point(0, 21);
this.checkedLis tBox1.Name = "checkedListBox 1";
this.checkedLis tBox1.Size = new System.Drawing. Size(150, 4);
this.checkedLis tBox1.TabIndex = 1;
this.checkedLis tBox1.ItemCheck += new
System.Windows. Forms.ItemCheck EventHandler(th is.checkedListB ox1_ItemCheck);
//
// CheckedDropDown
//
this.Controls.A dd(this.checked ListBox1);
this.Controls.A dd(this.comboBo x1);
this.Name = "CheckedDropDow n";
this.Size = new System.Drawing. Size(150, 24);
this.ResumeLayo ut(false);

}
#endregion

private void comboBox1_DropD own(object sender, System.EventArg s e)
{
//reveal the checked listbox and give it focus
this.Height = 128;
checkedListBox1 .Focus();
}

private void checkedListBox1 _ItemCheck(obje ct sender,
System.Windows. Forms.ItemCheck EventArgs e)
{
//hide the checked listbox
this.Height = comboBox1.Heigh t;
}
}
}
//END of code

Bear in mind that this is far from ideal! But it works.

You will need to use checkedListBox1 's items since that is where your
selected items will be ... the combobox is just there so the user can
click something to cause the dropdown event (which displays your
checkedListBox) .

HTH,
James.

Jan 15 '07 #4

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

Similar topics

3
4318
by: vgrssrtrs | last post by:
<html> <head> <script language="JavaScript"> <!-- /* *** Multiple dynamic combo boxes *** by Mirko Elviro, 9 Mar 2005 *** ***Please do not remove this comment
4
4280
by: Heather | last post by:
Hi I am desparately looking for advice in relation to storing the results after selecting items from two combo boxes on a Referral form. The first combo box 'ctl Type' displays a full list of Agency Types, then the 2nd combo box displays a list of Organisations, depending upon the Agency Type Selected. The first combo box 'ctlType' (Unbound), Row Source: to field in 'AgencyReferralType'.
4
375
by: David | last post by:
Hi, I have a report with a sub-report. On the sub-report I have the following data: Product | Qty | Print (As Checkbox) What I want to do is hide all lines in the sub-report where the Print checkbox is UN-CHECKED and show only the lines where the checkbox is CHECKED.
3
3652
by: hmiller | last post by:
Hey everyone, I am having a hell of a time trying to set this menu system up. Here's what I'm trying to do. Combo Box One; is populated by names under properties "row source" "Phase 1" through "Phase 10" (there are 10 Phases I want to sort from) Once the phase has been selected a second combo box would populate.
2
2451
by: kiranmn75 | last post by:
I want to dynamically populate a combo box through javascript. Data is coming from a array. Sometimes data list may contain items in excess of 2000. Explorer takes more than 5 seconds to populate the combo (for a list of 2500). Can anybody optimize the code. I tried Duffs devise instead of 'for loop', but no improvement.
2
7135
by: saurabhnsit2002 | last post by:
Can anyone help me about how to create combo box with its items as checked boxes or radio buttons. This has to be done in C#. I have seen something similar to this named custom combo boxes but they are in MFC I have to remain constrained only in C#. I have tried to add checked listbox in combobox drop down list but it is showing in text format i.e. name of the control added, if I change display property of combobox with some property of...
4
13683
by: sara | last post by:
Hi - I've looked at many posts, and cannot find the answer on this specific problem. I have several fields on a table, which I've defined as "Text", 3 characters, Format Yes/No (I picked up the Text and Format Yes/No from a Posting). I have a form with a label and a check box for each item and the user checks off the ones s/he wants to be "Yes".
6
3681
by: Dave | last post by:
I want to put the information that the user selects in my combo boxes into a subform that lies on the same form as the combo boxes. Thanks for your help already, Dave
0
8759
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
9199
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
8136
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6718
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
4524
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3236
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2671
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2161
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.