コード例 #1
0
        /// <summary>
        /// 条件查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolbtnSearch_Click(object sender, EventArgs e)
        {
            if (!query_flag)
            {
                query_flag = true;

                ZCGridColumnSortButton btnSort = null;
                foreach (DataGridViewColumn c in dbgClear.Columns)
                {
                    if (!c.Visible)
                    {
                        continue;
                    }
                    if (sortButtons.ContainsKey(c.HeaderText))
                    {
                        continue;
                    }
                    btnSort             = new ZCGridColumnSortButton();
                    btnSort.Text        = ".";
                    btnSort.Click      += btnSort_Click;
                    btnSort.Size        = new Size(16, 16);
                    btnSort.MinimumSize = btnSort.Size;
                    btnSort.sortHelper  = new ZCGridSortHelper();
                    this.sortButtons.Add(c.HeaderText, btnSort);
                    this.dbgClear.Controls.Add(btnSort);
                    btnSort.Visible = true;
                    btnSort         = this.sortButtons[c.HeaderText];
                    btnSort.Column  = dbgClear.Columns[c.Index];
                }
                SetupControlsPosition();
                this.toolbtnSelectItem.Enabled = false;
                this.toolbtnSearchAll.Enabled  = false;
                DataRefreshBySQL();
            }
            else
            {
                query_flag = false;
                if (this.frmSort != null)
                {
                    frmSort.Close();
                }
                foreach (string key in sortButtons.Keys)
                {
                    sortButtons[key].Dispose();
                }
                sortButtons.Clear();
                SortsString.Clear();
                OrderByString[0] = "";
                this.toolbtnSelectItem.Enabled = true;
                this.toolbtnSearchAll.Enabled  = true;
                DataRefreshBySQL();
            }
        }
コード例 #2
0
 private void SetupSortButtonsPosition()
 {
     foreach (string columnName in SelectedColumns)
     {
         if (this.dbgClear.Columns.Contains(columnName) == false || this.sortButtons.ContainsKey(columnName) == false)
         {
             continue;
         }
         DataGridViewColumn     col     = this.dbgClear.Columns[columnName];
         ZCGridColumnSortButton btnSort = this.sortButtons[columnName];
         Rectangle r = this.dbgClear.GetCellDisplayRectangle(col.DisplayIndex, -1, false);
         btnSort.Left = r.Right - btnSort.Width - 2;
         btnSort.Top  = r.Bottom - btnSort.Height - 2;
     }
 }
コード例 #3
0
        private void btnSort_Click(object sender, EventArgs e)
        {
            //DataRefreshBySQL();
            ZCGridColumnSortButton btn = sender as ZCGridColumnSortButton;

            btn.Checked = !btn.Checked;
            if (frmSort == null || frmSort.IsDisposed)
            {
                frmSort                  = new ZCGridSortForm(this.dbgClear, this.SortsString, this.sortButtons, this.OrderByString);
                frmSort.UpdateEvent     += new ZCGridSortForm.UpdateEventHandler(DataRefreshBySQLSort);
                frmSort.GetRowListEvent += new ZCGridSortForm.GetRowListEventHandler(GetRowListBySQL);
            }
            if (btn.Checked)
            {
                frmSort.ResetShow(btn);
            }
            else
            {
                frmSort.Visible = false;
            }
        }
コード例 #4
0
        internal void ResetShow(ZCGridColumnSortButton btn)
        {
            if (this.btn != null && this.btn.IsDisposed == false && this.btn.Equals(btn) == false)
            {
                this.btn.Checked = false;
            }

            this.btn         = btn;
            this.btn.Checked = true;

            this.cklList.Items.Clear();
            this.cklList.Items.Add("正在读取...");
            this.cklList.Enabled = false;
            this.checkListInitOk = false;
            this.helper          = this.btn.sortHelper;

            this.cbbFirstLogic.SelectedIndex = (int)helper.FirstKeyFilterType;
            this.txtFirstKey.Text            = helper.FirstKey;

            if (helper.KeyLinkType == ZCGridViewKeyLinkType.And)
            {
                this.rdoAnd.Checked = true;
            }
            else if (helper.KeyLinkType == ZCGridViewKeyLinkType.Or)
            {
                this.rdoOr.Checked = true;
            }
            else
            {
                this.rdoSingle.Checked = true;
            }

            this.cbbSecondLogic.SelectedIndex = (int)helper.SecondKeyFilterType;
            this.txtSecondKey.Text            = helper.SecondKey;

            this.bwReadList.RunWorkerAsync(this.btn.Column.Name);
            Application.DoEvents();

            this.Size = this.MinimumSize;
            Point p = this.dbgEq.PointToScreen(btn.Location);

            p.Y += btn.Height;

            this.Location = p;

            if (this.Right > Screen.PrimaryScreen.WorkingArea.Right)
            {
                this.Left = Screen.PrimaryScreen.WorkingArea.Right - this.Width;
            }
            if (this.Left < Screen.PrimaryScreen.WorkingArea.Left)
            {
                this.Left = Screen.PrimaryScreen.WorkingArea.Left;
            }
            if (this.Bottom > Screen.PrimaryScreen.WorkingArea.Bottom)
            {
                this.Top = Screen.PrimaryScreen.WorkingArea.Bottom - this.Height;
            }

            this.Show();
            this.cklList.Select();
        }