• 大小: 0.46M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-06-15
  • 语言: C#
  • 标签: 下拉  全选  

资源简介

winform下拉多选自定义控件(带全选).zip 

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace UserControlDLL
{
    /// 
    /// 带下拉框的用户控件
    /// 

    public partial class ComCheckBoxList : UserControl
    {
        private TextBox tbSelectedValue;
        private ButtonS btnSelect;//下拉箭头
        private LabelS lbGrip;//此LABEL用于设置可以拖动下拉窗体变化

        private CheckedListBox checkListBox;
        private Label lbSelectAll;//全选
        private Label lbSelectNo;//取消

        private Form frmCheckList;

        private Panel pnlBack;
        private Panel pnlCheck;

        private System.Drawing.Point DragOffset; //用于记录窗体大小变化的位置

        //单击列表项状态更改事件
        public delegate void CheckBoxListItemClick(object sender ItemCheckEventArgs e);
        public event CheckBoxListItemClick ItemClick;

        public ComCheckBoxList()
        {
            InitializeComponent();
            this.Name = “comBoxCheckBoxList“;
            this.Layout+=new LayoutEventHandler(ComCheckBoxList_Layout);

            //生成控件
            tbSelectedValue = new TextBox();
            tbSelectedValue.ReadOnly = true;
            tbSelectedValue.Borderstyle = Borderstyle.None;

            //下拉箭头
            this.btnSelect = new ButtonS();
            btnSelect.Flatstyle = Flatstyle.Flat;
            btnSelect.Click+=new EventHandler(btnSelect_Click);

            //全选
            this.lbSelectAll = new Label();
            lbSelectAll.BackColor = Color.Transparent;
            lbSelectAll.Text = “全选“;
            lbSelectAll.Size = new Size(40 20);
            lbSelectAll.ForeColor = Color.Blue;
            lbSelectAll.Cursor = Cursors.Hand ;
            lbSelectAll.TextAlign = ContentAlignment.MiddleCenter;
            lbSelectAll.Click+=new EventHandler(lbSelectAll_Click);

            //取消
            lbSelectNo = new Label();
            lbSelectNo.BackColor = Color.Transparent;
            lbSelectNo.Text = “取消“;
            lbSelectNo.Size = new Size(40 20);
            lbSelectNo.ForeColor = Color.Blue;
            lbSelectNo.Cursor = Cursors.Hand;
            lbSelectNo.TextAlign = ContentAlignment.MiddleCenter;
            lbSelectNo.Click+=new EventHandler(lbSelectNo_Click);

            //生成checkboxlist
            this.checkListBox = new CheckedListBox();
            checkListBox.Borderstyle = Borderstyle.None;
            checkListBox.Location = new Point(00);
            checkListBox.Checkonclick = true;
            checkListBox.ScrollAlwaysVisible = true;
            checkListBox.LostFocus +=new EventHandler(checkListBox_LostFocus);
            checkListBox.ItemCheck+=new ItemCheckEventHandler(checkListBox_ItemCheck);

            //窗体
            frmCheckList = new Form();
            frmCheckList.FormBorderstyle = FormBorderstyle.

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-01-04 15:54  WinFormComCheckBoxList\
     目录           0  2018-01-02 10:44  WinFormComCheckBoxList\WinFormComCheckBoxList\
     目录           0  2018-01-02 10:44  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\
     目录           0  2018-01-02 10:44  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\
     目录           0  2018-01-02 10:44  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\v15\
     文件       90624  2018-01-04 15:53  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\v15\.suo
     目录           0  2018-01-02 10:44  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\v15\Server\
     目录           0  2018-01-04 15:53  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\v15\Server\sqlite3\
     文件           0  2018-01-02 10:44  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\v15\Server\sqlite3\db.lock
     文件     1056768  2018-01-04 15:53  WinFormComCheckBoxList\WinFormComCheckBoxList\.vs\WinFormControl\v15\Server\sqlite3\storage.ide
     文件        1542  2016-08-15 10:32  WinFormComCheckBoxList\WinFormComCheckBoxList\UpgradeLog.xml
     目录           0  2018-01-04 15:53  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\
     目录           0  2016-08-15 10:32  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\bin\
     目录           0  2012-07-26 11:39  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\bin\Debug\
     文件       18944  2018-01-04 15:51  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\bin\Debug\UserControlDLL.dll
     文件       34304  2018-01-04 15:51  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\bin\Debug\UserControlDLL.pdb
     目录           0  2016-08-15 10:32  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\bin\Release\
     文件       15112  2018-01-04 15:53  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\ComCheckBoxList.cs
     文件        1402  2018-01-02 10:50  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\ComCheckBoxList.Designer.cs
     文件        5817  2018-01-02 10:50  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\ComCheckBoxList.resx
     文件        4351  2012-07-23 13:18  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\DataGridViewButton.cs
     文件        2175  2012-07-23 12:02  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\DataGridViewButton.Designer.cs
     文件        6190  2012-07-23 12:02  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\DataGridViewButton.resx
     目录           0  2012-07-23 11:44  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\
     目录           0  2018-01-04 13:46  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\
     文件         864  2018-01-04 12:02  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\DesignTimeResolveAssemblyReferences.cache
     文件        6811  2018-01-04 12:04  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
     文件           0  2018-01-04 12:02  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
     文件           0  2018-01-04 12:02  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
     文件           0  2018-01-04 12:02  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
     目录           0  2016-08-15 10:32  WinFormComCheckBoxList\WinFormComCheckBoxList\UserControlDLL\obj\Debug\TempPE\
............此处省略68个文件信息

评论

共有 条评论