Пример #1
0
 private void textBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         PopupGridView(e);
     }
     else if (e.KeyData == Keys.Up || e.KeyData == Keys.Down)
     {
         dataGridViewHost.Focus();
     }
 }
Пример #2
0
        public static void BindFocused(this ToolStripControlHost control, Field <bool> field)
        {
            bool isFocused = control.Focused;
            var  handler   = Bind(field, () => isFocused, x => { if (x)
                                                                 {
                                                                     control.Focus();
                                                                 }
                                  });

            control.GotFocus  += (sender, e) => { isFocused = true; handler(sender, e); };
            control.LostFocus += (sender, e) => { isFocused = false; handler(sender, e); };
        }
        void header_FilterButtonClicked(object sender, ColumnFilterClickedEventArg e)
        {
            int widthTool = GetWhithColumn(e.ColumnIndex) + 50;

            if (widthTool < 110)
            {
                widthTool = 110;
            }

            columnIndex = e.ColumnIndex;

            textBoxCtrl.Clear();
            CheckCtrl.Items.Clear();

            textBoxCtrl.Size         = new System.Drawing.Size(widthTool, 30);
            textBoxCtrl.TextChanged -= textBoxCtrl_TextChanged;
            textBoxCtrl.TextChanged += textBoxCtrl_TextChanged;

            DateTimeCtrl.Size         = new System.Drawing.Size(widthTool, 30);
            DateTimeCtrl.Format       = DateTimePickerFormat.Custom;
            DateTimeCtrl.CustomFormat = "dd.MM.yyyy";
            DateTimeCtrl.TextChanged -= DateTimeCtrl_TextChanged;
            DateTimeCtrl.TextChanged += DateTimeCtrl_TextChanged;

            CheckCtrl.ItemCheck   -= CheckCtrl_ItemCheck;
            CheckCtrl.ItemCheck   += CheckCtrl_ItemCheck;
            CheckCtrl.CheckOnClick = true;

            GetChkFilter();

            CheckCtrl.MaximumSize = new System.Drawing.Size(widthTool, GetHeightTable() - 120);
            CheckCtrl.Size        = new System.Drawing.Size(widthTool, (CheckCtrl.Items.Count + 1) * 18);

            ApplyButtonCtrl.Text   = ButtonCtrlText;
            ApplyButtonCtrl.Size   = new System.Drawing.Size(widthTool, 30);
            ApplyButtonCtrl.Click -= ApplyButtonCtrl_Click;
            ApplyButtonCtrl.Click += ApplyButtonCtrl_Click;

            ClearFilterCtrl.Text   = ClearFilterCtrlText;
            ClearFilterCtrl.Size   = new System.Drawing.Size(widthTool, 30);
            ClearFilterCtrl.Click -= ClearFilterCtrl_Click;
            ClearFilterCtrl.Click += ClearFilterCtrl_Click;

            popup.Items.Clear();
            popup.AutoSize = true;
            popup.Margin   = Padding.Empty;
            popup.Padding  = Padding.Empty;

            ToolStripControlHost host1 = new ToolStripControlHost(textBoxCtrl);

            host1.Margin   = Padding.Empty;
            host1.Padding  = Padding.Empty;
            host1.AutoSize = false;
            host1.Size     = textBoxCtrl.Size;

            ToolStripControlHost host2 = new ToolStripControlHost(CheckCtrl);

            host2.Margin   = Padding.Empty;
            host2.Padding  = Padding.Empty;
            host2.AutoSize = false;
            host2.Size     = CheckCtrl.Size;

            ToolStripControlHost host3 = new ToolStripControlHost(ApplyButtonCtrl);

            host3.Margin   = Padding.Empty;
            host3.Padding  = Padding.Empty;
            host3.AutoSize = false;
            host3.Size     = ApplyButtonCtrl.Size;

            ToolStripControlHost host4 = new ToolStripControlHost(ClearFilterCtrl);

            host4.Margin   = Padding.Empty;
            host4.Padding  = Padding.Empty;
            host4.AutoSize = false;
            host4.Size     = ClearFilterCtrl.Size;

            ToolStripControlHost host5 = new ToolStripControlHost(DateTimeCtrl);

            host5.Margin   = Padding.Empty;
            host5.Padding  = Padding.Empty;
            host5.AutoSize = false;
            host5.Size     = DateTimeCtrl.Size;

            switch (this.Columns[columnIndex].ValueType.ToString())
            {
            case "System.DateTime":
                popup.Items.Add(host5);
                break;

            default:
                popup.Items.Add(host1);
                break;
            }
            popup.Items.Add(host2);
            popup.Items.Add(host3);
            popup.Items.Add(host4);

            popup.Show(this, e.ButtonRectangle.X, e.ButtonRectangle.Bottom);
            host2.Focus();
        }
Пример #4
0
        // Цвет выделенной йчейки
        //private string cellColor { get; set; }

        // Событие кнопки фильтрации
        private void Header_FilterButtonClicked(object sender, ColumnFilterClickedEventArg e)
        {
            int widthTool = this.Columns[e.ColumnIndex].Width + 50;

            if (widthTool < 200)
            {
                widthTool = 200;
            }
            int heightTool = this.Height - 200;

            if (heightTool < 200)
            {
                heightTool = 200;
            }

            ColumnIndex = e.ColumnIndex;

            SearchTB.Clear();
            CheckLB.Items.Clear();

            SearchTB.Size         = new System.Drawing.Size(widthTool, 30);
            SearchTB.Text         = SearchTBText;
            SearchTB.ForeColor    = Color.Gray;
            SearchTB.MouseDown   -= SearchTB_MouseDown;
            SearchTB.MouseDown   += SearchTB_MouseDown;
            SearchTB.TextChanged -= SearchTB_TextChanged;
            SearchTB.TextChanged += SearchTB_TextChanged;

            DTP.Size         = new System.Drawing.Size(widthTool, 30);
            DTP.Format       = DateTimePickerFormat.Custom;
            DTP.CustomFormat = "dd.MM.yyyy";
            DTP.TextChanged -= DTP_TextChanged;
            DTP.TextChanged += DTP_TextChanged;

            CheckLB.ItemCheck   -= CheckLB_ItemCheck;
            CheckLB.ItemCheck   += CheckLB_ItemCheck;
            CheckLB.CheckOnClick = true;

            GetChkFilter();

            CheckLB.MaximumSize = new System.Drawing.Size(widthTool, heightTool);
            CheckLB.Size        = new System.Drawing.Size(widthTool, (CheckLB.Items.Count + 1) * 18);

            ApplyButton.Text   = ButtonCtrlText;
            ApplyButton.Size   = new System.Drawing.Size(widthTool, 30);
            ApplyButton.Click -= ApplyButton_Click;
            ApplyButton.Click += ApplyButton_Click;

            ClearAllButton.Text   = ClearAllButtonText;
            ClearAllButton.Size   = new System.Drawing.Size(widthTool, 30);
            ClearAllButton.Click -= ClearAllButton_Click;
            ClearAllButton.Click += ClearAllButton_Click;

            ClearButton.Text   = ClearButtonText;
            ClearButton.Size   = new System.Drawing.Size(widthTool, 30);
            ClearButton.Click -= ClearButton_Click;
            ClearButton.Click += ClearButton_Click;

            popup.Items.Clear();
            popup.AutoSize = true;
            popup.Margin   = Padding.Empty;
            popup.Padding  = Padding.Empty;

            ToolStripControlHost host1 = new ToolStripControlHost(SearchTB)
            {
                Margin   = Padding.Empty,
                Padding  = Padding.Empty,
                AutoSize = false,
                Size     = SearchTB.Size
            };
            ToolStripControlHost host2 = new ToolStripControlHost(CheckLB)
            {
                Margin   = Padding.Empty,
                Padding  = Padding.Empty,
                AutoSize = false,
                Size     = CheckLB.Size
            };
            ToolStripControlHost host3 = new ToolStripControlHost(ApplyButton)
            {
                Margin   = Padding.Empty,
                Padding  = Padding.Empty,
                AutoSize = false,
                Size     = ApplyButton.Size
            };
            ToolStripControlHost host4 = new ToolStripControlHost(ClearAllButton)
            {
                Margin   = Padding.Empty,
                Padding  = Padding.Empty,
                AutoSize = false,
                Size     = ClearAllButton.Size
            };
            ToolStripControlHost host5 = new ToolStripControlHost(DTP)
            {
                Margin   = Padding.Empty,
                Padding  = Padding.Empty,
                AutoSize = false,
                Size     = DTP.Size
            };
            ToolStripControlHost host6 = new ToolStripControlHost(ClearButton)
            {
                Margin   = Padding.Empty,
                Padding  = Padding.Empty,
                AutoSize = false,
                Size     = ClearButton.Size
            };

            switch (this.Columns[ColumnIndex].ValueType.ToString())
            {
            case "System.DateTime":
                popup.Items.Add(host5);
                break;

            default:
                popup.Items.Add(host1);
                break;
            }
            popup.Items.Add(host2);
            popup.Items.Add(host3);
            popup.Items.Add(host6);
            popup.Items.Add(host4);

            popup.Show(this, e.ButtonRectangle.X, e.ButtonRectangle.Bottom);
            host2.Focus();
        }