【问题标题】:How to add button to last row in gridvew of devexpress如何在devexpress的gridview中将按钮添加到最后一行
【发布时间】:2020-06-07 08:32:54
【问题描述】:

我想在下面。
enter image description here
我想在gridview的最后一行添加一个按钮。
有可能吗?

【问题讨论】:

    标签: c# gridview devexpress


    【解决方案1】:

    我已经使用页脚完成了这项工作。

            public static void CustomDrawFooter(DevExpress.XtraGrid.GridControl gridControl, GridView gridView)
            {
                gridView.OptionsView.ShowFooter = true;
                gridView.FooterPanelHeight = 40;
    
                // Handle this event to paint the footer panel manually
                gridView.CustomDrawFooter += (s, e) => {
                    int Hoffset = 10;
                    int Voffset = 5;
                    e.DefaultDraw();
    
                    markRectangle = new Rectangle(e.Bounds.X + Hoffset, e.Bounds.Y + Voffset, e.Bounds.Width - 2 * Hoffset, e.Bounds.Height - 2 * Voffset);
    
                    e.Appearance.BackColor = Color.White;
                    e.Appearance.FillRectangle(e.Cache, e.Bounds);
                    e.Appearance.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;
                    e.Appearance.ForeColor = Color.White;
                    e.Appearance.FontSizeDelta = 1;
                    e.Appearance.Font = new Font("Segoe UI Semibold", 10);
                    e.Appearance.Options.UseTextOptions = true;
                    e.Cache.FillRectangle(new SolidBrush(Color.FromArgb(184, 169, 126)), markRectangle);
                    e.Appearance.DrawString(e.Cache, "Show more items...", markRectangle);
    
                };
            }
    

    我添加了 MouseUp 事件。

            private void GridView_MouseUp(object sender, MouseEventArgs e)
            {
                GridHitInfo hitInfo = dmGridView.CalcHitInfo(e.Location);
                if(hitInfo.HitTest == GridHitTest.Footer)
                {
                    if ((e.Location.X >= markRectangle.X && e.Location.X <= markRectangle.X + markRectangle.Width) &&
                        (e.Location.Y >= markRectangle.Y && e.Location.Y <= markRectangle.Y + markRectangle.Height))
                        MessageBox.Show("HAHAHAHAHAH");
                }
            }
    

    这行得通。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-11
      • 1970-01-01
      • 2010-10-22
      相关资源
      最近更新 更多