Example #1
0
 public void changechecklistbox(CheckedListBox cb, int item, bool check)
 {
     if (cb.InvokeRequired)
     {
         changechecklistboxcallback Db = new changechecklistboxcallback(changechecklistbox);
         cb.BeginInvoke(Db, new object[] { cb, item, check });
     }
     else
     {
         cb.SetItemChecked(item, check);
     }
 }
        /// <summary>
        /// CheckedListBox_SelectedIndexChanged变化事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CheckedListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            //---检验当前任务空闲
            if ((sender == null) || (this.defaultTaskIdle == true))
            {
                return;
            }
            CheckedListBox clb = (CheckedListBox)sender;

            //---这里是为防止双击操作,如果没有,快速双击会导致状态解析错误
            CGenFuncDelay.GenFuncDelayms(150);
            //clb.Enabled = false;
            //---设置输入焦点
            //clb.Focus();
            if (clb.SelectedItem.ToString() == "NC")
            {
                clb.SetItemCheckState(clb.SelectedIndex, CheckState.Checked);
                clb.SetItemCheckState(clb.SelectedIndex, CheckState.Indeterminate);
            }
            else
            {
                //---后台线程执行函数
                Thread t = new Thread
                               (delegate()
                {
                    if (clb.InvokeRequired)
                    {
                        clb.BeginInvoke((EventHandler)
                                        (delegate
                        {
                            this.UI_CheckedListBox_SelectedIndexChanged(clb);
                        }));
                    }
                    else
                    {
                        this.UI_CheckedListBox_SelectedIndexChanged(clb);
                    }
                }
                               );
                //---校验线程有效
                if (t != null)
                {
                    //---后台任务
                    t.IsBackground = true;
                    //---启动任务
                    t.Start();
                }
                //this.UI_CheckedListBox_SelectedIndexChanged(clb);
            }
            //clb.Enabled = true;
        }
Example #3
0
        /// <summary>
        /// 状態変更時にメッセージボックスを表示する
        /// </summary>
        /// <param name="checkdListBox">チェックリストボックス</param>
        static void ItemCheckedEvent(CheckedListBox checkdListBox)
        {
            ItemCheckEventHandler handler = null;

            handler = delegate
            {
                MessageBox.Show("");
                checkdListBox.BeginInvoke((MethodInvoker) delegate
                {
                    checkdListBox.ItemCheck -= handler;
                });
            };
            checkdListBox.ItemCheck += handler;
        }
Example #4
0
        /// <summary>
        /// 状態変更時にメッセージボックスを表示する
        /// </summary>
        /// <param name="checkdListBox">チェックリストボックス</param>
        static void ChangeSelectedIndexEvent(CheckedListBox checkdListBox)
        {
            EventHandler handler = null;

            handler = delegate
            {
                MessageBox.Show("");
                checkdListBox.BeginInvoke((MethodInvoker) delegate
                {
                    checkdListBox.SelectedIndexChanged -= handler;
                });
            };
            checkdListBox.SelectedIndexChanged += handler;
        }
Example #5
0
        public string GetSelectedCheckListBoxIdx(CheckedListBox anything, int idx)
        {
            string rStr = string.Empty;

            anything.BeginInvoke((MethodInvoker) delegate {
                try
                {
                    rStr = (string)anything.Items[idx];
                }
                catch
                {
                }
            });
            return(rStr);
        }
Example #6
0
 public static void ClearChecked(this CheckedListBox chkListBox)
 {
     if (chkListBox.InvokeRequired)
     {
         Action <CheckedListBox> dSetListbox = ClearChecked;
         chkListBox.BeginInvoke(dSetListbox, new object[] { chkListBox });
     }
     else
     {
         foreach (int variable in chkListBox.CheckedIndices)
         {
             chkListBox.SetItemChecked(variable, false);
         }
     }
 }