当前位置:编程学习 > C#/ASP.NET >>

winform 程序 自定义控件属性 无法选择

问题如下 



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ths.Controls.Validate;
using System.ComponentModel;

namespace Ths.Controls.ExpandControls.ExpandDataGrid.ExpandDataGridViewColumn
{
    /// <summary>
    /// 文本
    /// </summary>
    public class ExpandDataGridViewTextBoxColumn : DataGridViewTextBoxColumn
    {
        private RegexType columnTypeName;
        [TypeConverter(typeof(EnumConverter))]
        [Category("Data")]
        [Browsable(true)]
        [DefaultValue(RegexType.无)]
        [Description("设置控件验证方式!")]
        public RegexType ColumnTypeName
        {
            get
            {
                return (RegexType)columnTypeName;
            }
            set
            {
                columnTypeName = value;
            }
        }
    }
}



枚举类型

    public enum RegexType
    {
        无,
        邮政编码,
        数字,
        电话号码,
        邮件,
        身份证号码
    }


如图无法选择,就是选择了也是不行,始终是默认的那个


--------------------编程问答-------------------- [img=http://b204.photo.store.qq.com/http_imgload.cgi?/rurl4_b=f914a803c65649326968544a7e34bfe835a9ecd6648b5e3c23eddf09ea05555b4043ef935b15468390f14eaf441148dc619d32c46f142697caf8edcc7282e0facfd894a346219888c9aa04102a2b88dec8d52082&a=204&b=204][/img]
--------------------编程问答-------------------- --------------------编程问答-------------------- 没有看出什么问题。
我用的是这个调用的
            frmPropertyGrid f = new frmPropertyGrid();//带PropertyGrid的Form
            System.Windows.Forms.DataGridViewTextBoxColumn t = new Ths.Controls.ExpandControls.ExpandDataGrid.ExpandDataGridViewColumn.ExpandDataGridViewTextBoxColumn();
            f.MainPropertyGrid.SelectedObject = t;//MainPropertyGrid:PropertyGrid控件
            f.ShowDialog(); --------------------编程问答--------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Ths.Controls.ExpandControls.ExpandDataGrid.ExpandDataGridViewColumn;
using Ths.Controls.Validate;

namespace Ths.Controls.ExpandControls.ExpandDataGrid
{
    public class ExpandDataGridView : DataGridView
    {
        public ExpandDataGridView()
        {
        }

        protected override void OnUserAddedRow(DataGridViewRowEventArgs e)
        {
            base.OnUserAddedRow(e);
        }

        protected override void OnRowLeave(DataGridViewCellEventArgs e)
        {
            base.OnRowLeave(e);
            for (int i = 0; i < this.Columns.Count; i++)
            {
                ExpandDataGridViewTextBoxColumn textBoxColumn = this.Columns[e.ColumnIndex] as ExpandDataGridViewTextBoxColumn;
                if (textBoxColumn != null)
                {
                    DataGridViewCell dc = this.Rows[e.RowIndex].Cells[e.ColumnIndex];                    
                }
            }
        }
    }
}


[img=http://b201.photo.store.qq.com/http_imgload.cgi?/rurl4_b=f914a803c65649326968544a7e34bfe870f286a07a9282a680335b14ef9f677c541ea73aac3a72e70b4c5447863f0fe04cdf75c66878aeae71562b968b932d5feee7ed0a6f3eef978c67e1dcb7727e829c2a5b49&a=207&b=201][/img] --------------------编程问答-------------------- --------------------编程问答-------------------- 你把图片传了csdn你的空间里,QQ图显示不出来, 帖子快沉了,顶起来, --------------------编程问答-------------------- 我这儿能看到图片啊
--------------------编程问答-------------------- 第一张图

第二张图
--------------------编程问答-------------------- --------------------编程问答--------------------

public class ExpandDataGridViewTextBoxColumn : DataGridViewTextBoxColumn
    {
        private RegexType columnTypeName;
        [TypeConverter(typeof(EnumConverter))]
        [Category("Data")]
        [Browsable(true)]
        [DefaultValue(RegexType.无)]
        [Description("设置控件验证方式!")]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public RegexType ColumnTypeName
        {
            get
            {
                return (RegexType)columnTypeName;
            }
            set
            {
                columnTypeName = value;
            }
        }
    }
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,