先贴代码:
如下是控件的部分代码: public partial class GridControlEx : GridControl
{
public GridControlEx()
{
InitializeComponent();
} private void InitializeComponent()
{
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.SuspendLayout();
//
// GridControlEx
//
this.EmbeddedNavigator.Buttons.Append.Visible = false;
this.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
this.EmbeddedNavigator.Buttons.Edit.Visible = false;
this.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
this.EmbeddedNavigator.Buttons.First.Visible = false;
this.EmbeddedNavigator.Buttons.Last.Visible = false;
this.EmbeddedNavigator.Buttons.Next.Visible = false;
this.EmbeddedNavigator.Buttons.NextPage.Visible = false;
this.EmbeddedNavigator.Buttons.Prev.Visible = false;
this.EmbeddedNavigator.Buttons.PrevPage.Visible = false;
this.EmbeddedNavigator.Buttons.Remove.Visible = false;
this.EmbeddedNavigator.CustomButtons.AddRange(
new DevExpress.XtraEditors.NavigatorCustomButton[] {
new DevExpress.XtraEditors.NavigatorCustomButton(0, -1, true, true, "首页", "FirstPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(1, -1, true, true, "上一页", "PrevPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(2, -1, true, true, "下一页", "NextPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(3, -1, true, true, "尾页", "LastPage")});
this.EmbeddedNavigator.TextStringFormat = "记录 {0}/{1}";
this.EmbeddedNavigator.ButtonClick += new DevExpress.XtraEditors.NavigatorButtonClickEventHandler(this.GridControlEx_EmbeddedNavigator_ButtonClick);
this.UseEmbeddedNavigator = true;
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout(false); }如下是控件使用生成的代码: //
// gridControlEx1
//
this.gridControlEx1.EmbeddedNavigator.Buttons.Append.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Edit.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.First.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Last.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Next.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.NextPage.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Prev.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.PrevPage.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Remove.Visible = false;
this.gridControlEx1.EmbeddedNavigator.CustomButtons.AddRange(new DevExpress.XtraEditors.NavigatorCustomButton[] {
new DevExpress.XtraEditors.NavigatorCustomButton(0, -1, true, true, "首页", "FirstPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(1, -1, true, true, "上一页", "PrevPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(2, -1, true, true, "下一页", "NextPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(3, -1, true, true, "尾页", "LastPage")});
this.gridControlEx1.EmbeddedNavigator.TextStringFormat = "记录 {0}/{1}";
this.gridControlEx1.Location = new System.Drawing.Point(329, 157);
this.gridControlEx1.Name = "gridControlEx1";
this.gridControlEx1.PageIndex = 0;
this.gridControlEx1.PageSize = 10;
this.gridControlEx1.RecordCount = 0;
this.gridControlEx1.Size = new System.Drawing.Size(400, 200);
this.gridControlEx1.TabIndex = 3;
this.gridControlEx1.UseEmbeddedNavigator = true;我怎样才能让使用时不重复,
红色部分是按钮,本意是只生成4个按钮,但使用控件时却变成了8个,主要原因是后面的代码自动添加了重复的代码,请问我怎样处理
如下是控件的部分代码: public partial class GridControlEx : GridControl
{
public GridControlEx()
{
InitializeComponent();
} private void InitializeComponent()
{
((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
this.SuspendLayout();
//
// GridControlEx
//
this.EmbeddedNavigator.Buttons.Append.Visible = false;
this.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
this.EmbeddedNavigator.Buttons.Edit.Visible = false;
this.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
this.EmbeddedNavigator.Buttons.First.Visible = false;
this.EmbeddedNavigator.Buttons.Last.Visible = false;
this.EmbeddedNavigator.Buttons.Next.Visible = false;
this.EmbeddedNavigator.Buttons.NextPage.Visible = false;
this.EmbeddedNavigator.Buttons.Prev.Visible = false;
this.EmbeddedNavigator.Buttons.PrevPage.Visible = false;
this.EmbeddedNavigator.Buttons.Remove.Visible = false;
this.EmbeddedNavigator.CustomButtons.AddRange(
new DevExpress.XtraEditors.NavigatorCustomButton[] {
new DevExpress.XtraEditors.NavigatorCustomButton(0, -1, true, true, "首页", "FirstPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(1, -1, true, true, "上一页", "PrevPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(2, -1, true, true, "下一页", "NextPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(3, -1, true, true, "尾页", "LastPage")});
this.EmbeddedNavigator.TextStringFormat = "记录 {0}/{1}";
this.EmbeddedNavigator.ButtonClick += new DevExpress.XtraEditors.NavigatorButtonClickEventHandler(this.GridControlEx_EmbeddedNavigator_ButtonClick);
this.UseEmbeddedNavigator = true;
((System.ComponentModel.ISupportInitialize)(this)).EndInit();
this.ResumeLayout(false); }如下是控件使用生成的代码: //
// gridControlEx1
//
this.gridControlEx1.EmbeddedNavigator.Buttons.Append.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.CancelEdit.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Edit.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.EndEdit.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.First.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Last.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Next.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.NextPage.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Prev.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.PrevPage.Visible = false;
this.gridControlEx1.EmbeddedNavigator.Buttons.Remove.Visible = false;
this.gridControlEx1.EmbeddedNavigator.CustomButtons.AddRange(new DevExpress.XtraEditors.NavigatorCustomButton[] {
new DevExpress.XtraEditors.NavigatorCustomButton(0, -1, true, true, "首页", "FirstPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(1, -1, true, true, "上一页", "PrevPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(2, -1, true, true, "下一页", "NextPage"),
new DevExpress.XtraEditors.NavigatorCustomButton(3, -1, true, true, "尾页", "LastPage")});
this.gridControlEx1.EmbeddedNavigator.TextStringFormat = "记录 {0}/{1}";
this.gridControlEx1.Location = new System.Drawing.Point(329, 157);
this.gridControlEx1.Name = "gridControlEx1";
this.gridControlEx1.PageIndex = 0;
this.gridControlEx1.PageSize = 10;
this.gridControlEx1.RecordCount = 0;
this.gridControlEx1.Size = new System.Drawing.Size(400, 200);
this.gridControlEx1.TabIndex = 3;
this.gridControlEx1.UseEmbeddedNavigator = true;我怎样才能让使用时不重复,
红色部分是按钮,本意是只生成4个按钮,但使用控件时却变成了8个,主要原因是后面的代码自动添加了重复的代码,请问我怎样处理
解决方案 »
- tablelayoutpanel 怎样合并单元格
- c# 热键问题。
- 关于Invalidate()
- c#从数据库中读出word文件,在磁盘生成临时word文件,在用Replace()方法替换其中超链接的时候,如果是大文件,或替换相当多的图片中的链接,效率太低,有没有好的替换方法???
- 一个textbox,要求里面一定要输入内容,否则在后面显示一句提醒,怎么做?
- winform问题
- C#发布程序管理问题
- .NET写的程序怎样才能在win98下运行? 7.1-7.2有效
- 求一條sql語句(自動生成編號)
- IComparable接口为什么有一个普通版本的,一个泛型版本的?
- c#向msn联系人发消息
- c#如何在winform confirm 对话框中添加 全部是 的确认按钮
就是这个地方的问题,控件初始化定义了一次,窗口中又自动生成了一次,其实所有的属性都重复了只不过没关系,但按钮就有问题了
//隐藏设计属性
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
//重新设置默认值
[DefaultValue(typeof(HorizontalAlignment), "Right")]
public new HorizontalAlignment TextAlign
{
get { return base.TextAlign; }
}控件被继承,你可以考虑重写被继承的属性,但要记得加new,不知我这样回答是不是你想要的。
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]