Thousand seperator does not work correctly in data gridview

柔情痞子 提交于 2019-12-18 09:46:54

问题


please let me explain it clearly, if there is misconception please let me know,

firstly you suppose I have a grid with three column:

ItemName Count Fee

my code works perfectly when I click on ItemName and the go to fee column, mean in this case when I type 12345 it becomes 12,345 actually when I am typing.

but when I go to count column and then fee column it does not work for example when I am typing 12345 it does not put comma.

my code:

Public Override  string Text
{
    get
    {
        return base.Text;
    }

    set
    {
        base.Text=GetFormattedText(value);
    }
}


protected override void OnTextChanged(System.EventArgs e)
{
    base.OnTextChanged(e);
    Text= GetFormattedText(Text);
}

Protected virtual string GetFormattedText(string Text)
{
    string strText= text.Replace(",","");
    decimal  decValue=System.Convert.ToDecimal(strText);

    strText= decValue.Tostring("#,##0");
    Return strText;
}

More explanation I am sure something is wrong with the GET of my property, because in this case, I mean when I go firstly to count column and then fee column it just calls get and doesn't go to OnTextChanged,

I know my question seems stupid because of my little knowledge but I really appreciate it if you could share some ideas

来源:https://stackoverflow.com/questions/41115117/thousand-seperator-does-not-work-correctly-in-data-gridview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!