日期:2014-05-19  浏览次数:20856 次

请教大家一个关于自定义DataGridViewColumn的问题,急,高手来帮帮忙啊!!!
我在写一个自定义的DataGridViewColumn对象,功能是该列的单元格用来输入密码,因此必需象文本框的UseSystemPasswordChar功能。大部分都写好了,可以最后发现该列中无法输入 q 字符,不知道为什么,好晕啊,高手帮我看看有什么问题!!谢谢了!!我的思路是把单元格的值用*来替换,把真实的值保存在TAG中,编辑的时候用从TextBox继承的编辑控件来编辑。下面是代码
using   System;
using   System.Collections.Generic;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Text;
using   System.Windows.Forms;

namespace   gif2seal
{
        public   class   TextBoxColumn   :   DataGridViewColumn
        {
                public   TextBoxColumn()
                        :   base(new   TextBoxCell())
                {
                }

                public   override   DataGridViewCell   CellTemplate
                {
                        get
                        {
                                return   base.CellTemplate;
                        }
                        set
                        {
                                //   Ensure   that   the   cell   used   for   the   template   is   a   TextBoxCell.
                                if   (value   !=   null   &&   !value.GetType().IsAssignableFrom(typeof(TextBoxCell)))
                                {
                                        throw   new   InvalidCastException( "Must   be   a   TextBoxCell ");
                                }
                                base.CellTemplate   =   value;
                        }
                }
        }

        public   class   TextBoxCell   :   DataGridViewTextBoxCell
        {

                public   TextBoxCell()
                        :   base()
                {
        &n