PDA

View Full Version : تعیین فرمت تکست باکس



bita_naz
شنبه 15 فروردین 1388, 22:22 عصر
فرمت تکست باکس برای مقادیر عددی یا پول رو چطور تعیین کنم ؟؟؟
می خام سه تا سه تا از هم جدا بشه

مرسی:لبخندساده:

rezatati
یک شنبه 16 فروردین 1388, 00:16 صبح
با سلام
با استفاده از این کد می تونی این کارو انجام بدی فقط کافی این کد رو تو ی Event Leave بنویسی


static string strCrncySymbol = "ریال";
static string strCrncyGrpSep = ",";
public static string ToCurrency(string InputString)
{
if (InputString.IndexOf(strCrncySymbol) > 0)
{
InputString = InputString.Replace(strCrncySymbol, String.Empty);
}

// del strCrncyGrpSep = "," if exist
if (InputString.IndexOf(strCrncyGrpSep) > 0)
{
InputString = InputString.Replace(strCrncyGrpSep, String.Empty);
}

// convert value to "#,#" style without decimal point
decimal d;
decimal.TryParse(InputString, out d);
InputString = d.ToString("#,#");

//add strCrncySymbol = "ریال" to value
InputString = InputString.Insert(InputString.Length, strCrncySymbol);
return InputString;
}