首页 > 其他 > 详细

在文本框单元中添加了一个小的按钮

时间:2020-07-09 19:02:05      阅读:134      评论:0      收藏:0      [点我收藏+]

 

  private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            if (e.Control is DataGridViewTextBoxEditingControl)
            {
                Button btn = new Button();
                btn.Height = e.Control.Height;
                btn.Width = e.Control.Width / 6;
                btn.Top = 0;
                btn.Left = e.Control.Width - btn.Width;
                btn.Cursor = Cursors.Default;
                btn.Click += new EventHandler(btn_Click);
                btn.Dock = DockStyle.Right;
                textbox.Controls.Clear();
                textbox.Controls.Add(btn);
            }
        }

        void btn_Click(object sender, EventArgs e)
        {
            Form f = new Form();
            f.StartPosition = FormStartPosition.Manual;
            Button btn = sender as Button;
            Rectangle bound = btn.Parent.RectangleToScreen(btn.Bounds);
            f.Location = new Point(bound.Left, bound.Height + bound.Top);
            f.Show(this);
        }

 

在文本框单元中添加了一个小的按钮

原文:https://www.cnblogs.com/kevinl/p/13275045.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!