本文整理汇总了C#中System.Globalization.CultureInfo.ClearCachedData方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ClearCachedData方法的具体用法?C# CultureInfo.ClearCachedData怎么用?C# CultureInfo.ClearCachedData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CultureInfo
的用法示例。
在下文中一共展示了CultureInfo.ClearCachedData方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
private string Execute(string DecimalNumber, int Precision)
{
try
{
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
string prefix = "";
if (_NegativeSign && DecimalNumber.IndexOf(nmfi.NegativeSign) == 0)
{
DecimalNumber = DecimalNumber.TrimStart(Convert.ToChar(nmfi.NegativeSign));
prefix = nmfi.NegativeSign;
}
if (DecimalNumber.Trim() == "")
{
DecimalNumber = "0";
}
Decimal m_decTemp = Math.Round(Convert.ToDecimal(DecimalNumber, nmfi), Precision);
//string m_strTemp = "0", m_strLocal = nmfi.NumberDecimalSeparator;
//for(int k=0; k < Precision; k++)
// m_strLocal += "0";
//m_strTemp += m_strLocal;
string rep = m_decTemp.ToString(nmfi);
string originalIntPortion;
string originalDecPortion;
int index = DecimalNumber.LastIndexOf(nmfi.NumberDecimalSeparator);
if(index == -1)
{
originalIntPortion = DecimalNumber;
string m_strTemp = ""; ////SHASHWATA
m_strTemp = nmfi.NumberDecimalSeparator; ////SHASHWATA
for (int k = 0; k < Precision; k++)////SHASHWATA
m_strTemp += "0";////SHASHWATA
originalDecPortion = m_strTemp;////SHASHWATA
//originalDecPortion = nmfi.NumberDecimalSeparator + "0";
}
else
{
originalIntPortion = DecimalNumber .Substring (0,index);
//originalDecPortion = nmfi.NumberDecimalSeparator + DecimalNumber.Substring(index+1);
}
//return originalIntPortion + originalDecPortion;
if (originalIntPortion == "") originalIntPortion = "0";
string newIntPortion;
index = rep.LastIndexOf(nmfi.NumberDecimalSeparator);
if (index == -1)
{
newIntPortion = rep;
}
else
{
newIntPortion = rep.Substring(0, index);
}
if (newIntPortion == "") newIntPortion = "0";
rep = prefix + rep.Replace(newIntPortion + nmfi.NumberDecimalSeparator, originalIntPortion + nmfi.NumberDecimalSeparator);
return rep;
}
catch(SystemException)
{
return "";
}
}
示例2: OnKeyDown
protected override void OnKeyDown(KeyEventArgs e)
{
if (ICTEAS.WinForms.Common.clsCommonInfo.ProcessInProgress)
{
e.Handled = true;
return;
}
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
blJustGotFocus = false;
blJustGotFocus = false;
iBeforeTxtChange = this.Text.Length;
iSelectionStart = this.SelectionStart;
iSelectionLength = this.SelectionLength;
iAfterTxtChange = -1;
if(e.KeyData == Keys.Delete)
{
if(m_Type == TypeEnum.String)
{
base.OnKeyDown (e);
return;
}
if( m_Type == TypeEnum.Integer )
{
if( _isCurrency )
{
if (this.SelectionStart > 0
&& this.Text.Length > this.SelectionStart
&& this.Text.Substring(this.SelectionStart, 1) == nmfi.NumberGroupSeparator
)
{
iSelectionStart = this.SelectionStart = this.SelectionStart + 1;
e.Handled = true;
return;
}
}
base.OnKeyDown(e);
return;
}
if ((intDotIndex = this.Text.IndexOf(nmfi.NumberDecimalSeparator)) >= 0)
{
if(this.SelectionStart > intDotIndex)
{
if(this.SelectionStart >= intDotIndex + m_intDecimalPrecision + 1)
e.Handled = true;
else
{
iSelectionLength = this.SelectionLength = 1;
this.SelectedText = "0";
e.Handled = true;
}
}
else if(this.SelectionStart == intDotIndex)
{
iSelectionStart = this.SelectionStart = this.SelectionStart + 1;
e.Handled = true;
}
else if( _isCurrency )
{
if (this.SelectionStart > 0
&& this.Text.Length > this.SelectionStart
&& this.Text.Substring(this.SelectionStart, 1) == nmfi.NumberGroupSeparator
)
{
base.OnKeyDown(e);
iSelectionStart = this.SelectionStart = this.SelectionStart - 1;
}
else
iSelectionStart = this.SelectionStart + 1;
}
else
{
base.OnKeyDown(e);
return;
}
}
}
else
base.OnKeyDown(e);
}
示例3: OnKeyPress
protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e)
{
if (ICTEAS.WinForms.Common.clsCommonInfo.ProcessInProgress)
{
e.Handled = true;
}
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
if (m_Type == TypeEnum.String)
{
//e.Handled = false;
base.OnKeyPress(e);
}
else
{
char[] arrDecimalSeperator = nmfi.NumberDecimalSeparator.ToCharArray();
char chrDecimalSeperator = arrDecimalSeperator[0];
if (char.IsNumber(e.KeyChar) || (e.KeyChar == 8) || (e.KeyChar == chrDecimalSeperator) || (e.KeyChar == 45))
{
if(e.KeyChar == 45)
{
if(_NegativeSign)
{
if (this.Text.IndexOf(nmfi.NegativeSign) == -1 && this.SelectionStart == 0)
{
base.OnKeyPress(e);
}
else
e.Handled = true;
}
else
{
e.Handled = true;
}
}
//handle DOT
else if (e.KeyChar == chrDecimalSeperator)
{
if (m_Type == TypeEnum.Float)
{
//decimal allowed
if (this.Text.IndexOf(nmfi.NumberDecimalSeparator) == -1)
{
CutString();
//e.Handled = false;
base.OnKeyPress(e);
}
else
{
//already "." found
e.Handled = true;
iSelectionStart = this.SelectionStart = this.Text.IndexOf(nmfi.NumberDecimalSeparator) + 1;
}
}
else
e.Handled = true;
}
else
{
//handle NUMBERs and BACKSPACE
//allow backspace
if (e.KeyChar == 8)
{
if(m_Type == TypeEnum.Float)
{
if ((intDotIndex = this.Text.IndexOf(nmfi.NumberDecimalSeparator)) >= 0)
{
if (this.SelectionLength > 0)
{
string m_strTemp = this.SelectedText;
int m_intTemp = m_strTemp.IndexOf(nmfi.NumberDecimalSeparator);
if (m_intTemp >= 0)
{
this.SelectedText = "";
//this.SelectionStart = this.SelectionStart;
}
else if (this.SelectionStart > intDotIndex)
{
int m_intSelectionStart = this.SelectionStart;
m_strTemp = "";
for (int i = 0; i < this.SelectionLength; i++)
m_strTemp += "0";
this.SelectedText = m_strTemp;
iSelectionLength = m_strTemp.Length;
iSelectionStart = this.SelectionStart = m_intSelectionStart - 1;
}
else
{
CutString();
base.OnKeyPress(e);
}
}
else if (this.SelectionStart >= intDotIndex + 1)
{
if (this.SelectionStart > intDotIndex + 1)
{
//.........这里部分代码省略.........
示例4: strInCommaFormat
private string strInCommaFormat(string strParamTextinComma)
{
try
{
strstoretext=strParamTextinComma;
noofcommas = 0;
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
string strTextinComma = strParamTextinComma;
bool flag = false;
string integerPart = "";
string DecimalPart = "";
int dotIndex = strTextinComma.LastIndexOf(Convert.ToChar(nmfi.NumberDecimalSeparator));
if (dotIndex == -1)
{
dotIndex = strTextinComma.Length;
DecimalPart = strTextinComma.Substring(dotIndex);
integerPart = strTextinComma.Substring(0, dotIndex);
if (isCurrency && Type == TypeEnum.Float)
{
int dpres = this.DecimalPrecision;
string tmp = String.Empty;
for (int k = 0; k < dpres; k++)
tmp = tmp + "0";
DecimalPart = tmp;
flag = true;
}
}
else
{
DecimalPart = strTextinComma.Substring(dotIndex + 1);
if (this.DecimalPrecision < DecimalPart.Length)
{
DecimalPart=nmfi.NumberDecimalSeparator+DecimalPart;
decimal val = Convert.ToDecimal(DecimalPart);
int counter = 0;
int totalcount = DecimalPart.Length - this.DecimalPrecision;
val = Math.Round(val, this.DecimalPrecision);
DecimalPart = val.ToString();
string[] pos = DecimalPart.Split(Convert.ToChar(nmfi.NumberDecimalSeparator));
DecimalPart = pos[1];
}
integerPart = strTextinComma.Substring(0, dotIndex);
flag = true;
}
integerPart = integerPart.Replace(nmfi.NumberGroupSeparator, "");
string prefix = "";
if (_NegativeSign && integerPart.IndexOf(nmfi.NegativeSign) == 0)
{
integerPart = integerPart.TrimStart(Convert.ToChar(nmfi.NegativeSign));
prefix = nmfi.NegativeSign;
}
int commasalreadyinintpart = this.find_no_occurences(strParamTextinComma, nmfi.NumberGroupSeparator);
if (integerPart.Length >= this.CommaPrecision)
{
int temp = integerPart.Length;
for (int k = this.CommaPrecision; k < temp; k += this.CommaPrecision)
{
integerPart = integerPart.Insert(temp - k, nmfi.NumberGroupSeparator);
noofcommas++;
}
noofcommas = noofcommas - commasalreadyinintpart;
}
if (flag)
strTextinComma = prefix + integerPart + nmfi.NumberDecimalSeparator + DecimalPart;
else
strTextinComma = prefix + integerPart;
edited = true;
return strTextinComma;
}
catch (Exception ex)
{
return strstoretext;
}
}
示例5: clsTxtBox_Leave
protected virtual void clsTxtBox_Leave(object sender,EventArgs e)
{
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
//if (!this.Focused)
// return;
if((isCurrency)&&(Type != TypeEnum .String ))
{
if(!OkString())
{
//ignore moving off cell if bad date
return;
}
}
if(this.Type ==TypeEnum.Float && this.AllowBlankInFloatValue == false)
{
bool txtch = this.TxtChange;
this.Text = Execute(this.Text, this.DecimalPrecision);
if(!txtch) this.RefreshChange();
}
else if(this.Type == TypeEnum.Integer)
{
bool txtch = this.TxtChange;
if (this.Text == nmfi.NegativeSign)
this.Text = "";
if(!txtch) this.RefreshChange();
}
}
示例6: ChangeDataTable
/// <summary>
/// Changes all the values at numeric column indices into comma-separated value if the datasource/datable
/// </summary>
private void ChangeDataTable()
{
try
{
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
int m_intColPos = -1;
for (int i = 0; i < dtSource.Columns.Count; i++)
{
if (CheckNumericColumn(i, ref m_intColPos))
{
clsTxtBox.TypeEnum objEnum = (clsTxtBox.TypeEnum)arlNumericColumnType[m_intColPos];
if (objEnum == clsTxtBox.TypeEnum.Float)
{
int m_intFloatSize = (int)arlNumericColFloatSize[m_intColPos];
for (int j = 0; j < dvSource.Count; j++)
{
// changed on 14/05/07 by Nilanjan (inclusion of group seperarors in wrong location
if (dvSource[j][i].ToString() != "")
{
string prefix = "";
string strFloat = dvSource[j][i].ToString();
strFloat = strFloat.Replace(".", nmfi.NumberDecimalSeparator);
decimal m_decTemp = Math.Round(Convert.ToDecimal(strFloat, nmfi), m_intFloatSize);
string rep = m_decTemp.ToString(nmfi);
int groupsize = nmfi.NumberGroupSizes[0];
int dotIndex = rep.LastIndexOf(Convert.ToChar(nmfi.NumberDecimalSeparator));
string DecimalPart = "", integerPart;
if (dotIndex == -1)
{
dotIndex = rep.Length;
DecimalPart = rep.Substring(dotIndex);
integerPart = rep.Substring(0, dotIndex);
int dpres = nmfi.NumberDecimalDigits;
string tmp = String.Empty;
for (int k = 0; k < dpres; k++)
tmp = tmp + "0";
DecimalPart = tmp;
}
else
{
DecimalPart = rep.Substring(dotIndex + 1);
integerPart = rep.Substring(0, dotIndex);
if (integerPart.Contains(nmfi.NegativeSign))
{
prefix = "-";
integerPart = integerPart.Remove(0, 1);
}
if (integerPart.Length >= nmfi.NumberDecimalDigits)
{
int temp = integerPart.Length;
for (int k = groupsize; k < temp; k += groupsize)
{
integerPart = integerPart.Insert(temp - k, nmfi.NumberGroupSeparator);
}
}
rep = prefix + integerPart + nmfi.NumberDecimalSeparator + DecimalPart;
}
//.......
dvSource[j][i] = rep;
}
}
}
}
}
dvSource.Table.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Source + " - " + ex.Message);
return;
}
}
示例7: ReplaceValue
public void ReplaceValue(int RowNum, int ColNum, string ReplaceString)
{
//Changed 26 06 2008
int _colNum = this.CurrentCell.ColumnIndex;
int _rowNum = this.CurrentCell.RowIndex;
//this.Refresh();
//--------------------
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
int m_intColPos = -1;
if (CheckNumericColumn(get_actual_colum_index(ColNum), ref m_intColPos))
{
clsTxtBox.TypeEnum objEnum = (clsTxtBox.TypeEnum)arlNumericColumnType[m_intColPos];
if (objEnum == clsTxtBox.TypeEnum.Float)
{
#region Float
if (ReplaceString == "")
ReplaceString = "0";
int m_intPrecision = (int)arlNumericColFloatSize[m_intColPos];
Decimal m_decTemp = Math.Round(Convert.ToDecimal(ReplaceString, nmfi), m_intPrecision);
string m_strTemp = "0", m_strLocal = nmfi.NumberDecimalSeparator;
for (int k = 0; k < m_intPrecision; k++)
m_strLocal += "0";
m_strTemp += m_strLocal;
//string rep = m_decTemp.ToString("###" + m_strTemp + ";",nmfi); //###" + m_strTemp + ";"+ m_strLocal);
string rep = m_decTemp.ToString(nmfi); //###" + m_strTemp + ";"+ m_strLocal);
//int ind = ReplaceString.LastIndexOf(".");//Change On 19/1/2007
int ind = ReplaceString.LastIndexOf(nmfi.NumberDecimalSeparator);
if (ind < 0)
{
}
else
{
string originalIntPortion = ReplaceString.Substring(0, ind);
if (originalIntPortion == "") originalIntPortion = "0";
string nextIntPortion = rep.Substring(0, rep.LastIndexOf(nmfi.NumberDecimalSeparator));
if (nextIntPortion == "") nextIntPortion = "0";
rep = rep.Replace(nextIntPortion, originalIntPortion);
}
//dvSource[RowNum][ColNum] = rep;
//this.Nodes[RowNum].Cells[ColNum].Value = rep;
this.GetNodeForRow(RowNum).Cells[ColNum].Value = rep;
#endregion
}
else
{
//this.Nodes[RowNum].Cells[ColNum].Value = ReplaceString;
this.GetNodeForRow(RowNum).Cells[ColNum].Value = Convert.ToDouble(ReplaceString);// String.Format("{0:0,0}", ReplaceString); //ReplaceString;
}
}
else
{
//this.Nodes[RowNum].Cells[ColNum].Value =ReplaceString;
this.GetNodeForRow(RowNum).Cells[ColNum].Value = ReplaceString;
}
//this.CurrentCell = this.Rows[_rowNum].Cells[get_actual_colum_index(_colNum)];
//-------------------------------------
this.BeginEdit(true);
CultureInfo inf = new CultureInfo(CultureInfo.CurrentCulture.LCID, true);
inf.NumberFormat.NumberGroupSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator;
inf.NumberFormat.NumberDecimalSeparator = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator;
this.DefaultCellStyle.FormatProvider = inf;
this.DefaultCellStyle.FormatProvider = inf;
}
示例8: strInCommaFormat
/// <summary>
/// Processes a string input and returns it in comma separated format
/// </summary>
/// <param name="strParamTextinComma"></param>
/// <param name="columnindex"></param>
/// <param name="start"></param>
/// <returns></returns>
public string strInCommaFormat(string strParamTextinComma, int columnindex, ref int start)
{
string strstoretext = "";
try
{
int realindex = columnindex;
strstoretext = strParamTextinComma;
int noofcommas = 0;
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
string strTextinComma = strParamTextinComma;
bool flag = false;
string integerPart = "";
string DecimalPart = "";
int dotIndex = strTextinComma.LastIndexOf(Convert.ToChar(nmfi.NumberDecimalSeparator));
int columnnumber = 0;
for (columnnumber = 0; columnnumber < arlNumericColumNum.Count; columnnumber++)
{
if ((int)arlNumericColumNum[columnnumber] == realindex)
{
break;
}
}
int DecimalPrecision = (int)arlNumericColFloatSize[columnnumber];
int CommaPrecision = 3;
if (dotIndex == -1)
{
dotIndex = strTextinComma.Length;
DecimalPart = strTextinComma.Substring(dotIndex);
integerPart = strTextinComma.Substring(0, dotIndex);
bool test;
if (arlNumericColCurrency.Count > columnnumber)
{
test = (bool)arlNumericColCurrency[columnnumber];
}
else
{
test = false;
}
if (test && (clsTxtBox.TypeEnum)arlNumericColumnType[columnnumber] == clsTxtBox.TypeEnum.Float)
{
int dpres = 4;
string tmp = String.Empty;
for (int k = 0; k < dpres; k++)
tmp = tmp + "0";
DecimalPart = tmp;
flag = true;
}
}
else
{
DecimalPart = strTextinComma.Substring(dotIndex + 1);
if (DecimalPrecision < DecimalPart.Length)
{
DecimalPart = nmfi.NumberDecimalSeparator + DecimalPart;
decimal val = Convert.ToDecimal(DecimalPart);
int counter = 0;
int totalcount = DecimalPart.Length - DecimalPrecision;
val = Math.Round(val, DecimalPrecision);
DecimalPart = val.ToString();
string[] pos = DecimalPart.Split(Convert.ToChar(nmfi.NumberDecimalSeparator));
DecimalPart = pos[1];
}
integerPart = strTextinComma.Substring(0, dotIndex);
flag = true;
}
integerPart = integerPart.Replace(nmfi.NumberGroupSeparator, "");
string prefix = "";
if (integerPart.IndexOf(nmfi.NegativeSign) == 0)
{
integerPart = integerPart.TrimStart(Convert.ToChar(nmfi.NegativeSign));
prefix = nmfi.NegativeSign;
}
int commasalreadyinintpart = this.find_no_occurences(strParamTextinComma, nmfi.NumberGroupSeparator);
if (integerPart.Length >= CommaPrecision)
{
int temp = integerPart.Length;
for (int k = CommaPrecision; k < temp; k += CommaPrecision)
{
//.........这里部分代码省略.........
示例9: ReplaceValueWithFocus
public void ReplaceValueWithFocus(int RowNum, int ColNum, string ReplaceString)
{
//Changed 26 06 2008
int _colNum = this.CurrentCell.ColumnIndex;
int _rowNum = this.CurrentCell.RowIndex;
dvSource[this.CurrentRow.Index][get_actual_colum_index(this.CurrentCell.ColumnIndex)] = this.Rows[this.CurrentRow.Index].Cells[this.CurrentCell.ColumnIndex].EditedFormattedValue.ToString();
dvSource.Table.AcceptChanges();
this.DataSource = dvSource.Table;
this.Update();
this.Refresh();
//--------------------
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
int m_intColPos = -1;
if (CheckNumericColumn(ColNum, ref m_intColPos))
{
clsTxtBox.TypeEnum objEnum = (clsTxtBox.TypeEnum)arlNumericColumnType[m_intColPos];
if (objEnum == clsTxtBox.TypeEnum.Float)
{
#region Float
if (ReplaceString == "")
ReplaceString = "0";
int m_intPrecision = (int)arlNumericColFloatSize[m_intColPos];
Decimal m_decTemp = Math.Round(Convert.ToDecimal(ReplaceString, nmfi), m_intPrecision);
string m_strTemp = "0", m_strLocal = nmfi.NumberDecimalSeparator;
for (int k = 0; k < m_intPrecision; k++)
m_strLocal += "0";
m_strTemp += m_strLocal;
//string rep = m_decTemp.ToString("###" + m_strTemp + ";",nmfi); //###" + m_strTemp + ";"+ m_strLocal);
string rep = m_decTemp.ToString(nmfi); //###" + m_strTemp + ";"+ m_strLocal);
//int ind = ReplaceString.LastIndexOf(".");//Change On 19/1/2007
int ind = ReplaceString.LastIndexOf(nmfi.NumberDecimalSeparator);
if (ind < 0)
{
}
else
{
string originalIntPortion = ReplaceString.Substring(0, ind);
if (originalIntPortion == "") originalIntPortion = "0";
string nextIntPortion = rep.Substring(0, rep.LastIndexOf(nmfi.NumberDecimalSeparator));
if (nextIntPortion == "") nextIntPortion = "0";
rep = rep.Replace(nextIntPortion, originalIntPortion);
}
dvSource[RowNum][ColNum] = rep;
#endregion
}
else
{
dvSource[RowNum][ColNum] = ReplaceString;
}
}
else
{
dvSource[RowNum][ColNum] = ReplaceString;
}
dvSource.Table.AcceptChanges();
this.DataSource = dvSource.Table;
this.Update();
this.Refresh();
//DataGridViewCell cell=this.
this.CurrentCell = this.Rows[RowNum].Cells[get_actual_colum_index(ColNum)];
//Changed 26 06 2008
SetRowStatus(RowNum);
//this.CurrentCell = this.Rows[_rowNum].Cells[get_actual_colum_index(_colNum)];
////this.CurrentCell.DataGridView.EditingControl.te
//EditingControl cntrl = (EditingControl)this.CurrentCell.DataGridView.EditingControl;
//-------------------------------------
this.BeginEdit(true);
//this.SelectedRows[RowNum].Cells[ColNum].Selected = true;
}
示例10: ReplaceInReadOnlyColumn
public void ReplaceInReadOnlyColumn(int RowNum, int ColNum, string ReplaceString)
{
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
this.CurrentRowIndex = RowNum;
int m_intColPos = -1;
if (CheckNumericColumn(ColNum, ref m_intColPos))
{
string rep = "";
clsTxtBox.TypeEnum objEnum = (clsTxtBox.TypeEnum)arlNumericColumnType[m_intColPos];
if (objEnum == clsTxtBox.TypeEnum.Float)
{
if (ReplaceString == "")
ReplaceString = "0";
int m_intPrecision = (int)arlNumericColFloatSize[m_intColPos];
Decimal m_decTemp = Math.Round(Convert.ToDecimal(ReplaceString, nmfi), m_intPrecision);
string m_strTemp = "0", m_strLocal = nmfi.NumberDecimalSeparator;
for (int k = 0; k < m_intPrecision; k++)
m_strLocal += "0";
m_strTemp += m_strLocal;
rep = m_decTemp.ToString(nmfi);
int ind = ReplaceString.LastIndexOf(nmfi.NumberDecimalSeparator);
if (ind < 0)
{
}
else
{
string originalIntPortion = ReplaceString.Substring(0, ind);
if (originalIntPortion == "") originalIntPortion = "0";
string nextIntPortion = rep.Substring(0, rep.LastIndexOf(nmfi.NumberDecimalSeparator));
if (nextIntPortion == "") nextIntPortion = "0";
rep = rep.Replace(nextIntPortion, originalIntPortion);
}
}
else
rep = ReplaceString;
dvSource[RowNum][ColNum] = rep;
}
else if (CheckComboBoxColumn(ColNum, ref m_intColPos))
{
dvSource[RowNum][ColNum] = ReplaceString;
}
else if (CheckDateTimeColumn(ColNum, ref m_intColPos))
{
dvSource[RowNum][ColNum] = ReplaceString;
}
else
{
dvSource[RowNum][ColNum] = ReplaceString;
}
this.SetRowStatus(RowNum);
this.SetTxtChange();
dvSource.Table.AcceptChanges();
this.Update();
this.Refresh();
}
示例11: ReplaceValue
/// <summary>
///Replace the datagrid cell with ReplaceString.
/// </summary>
/// <param name="RowNum">Datagrid Row Number</param>
/// <param name="ColNum">Datagrid Column Number</param>
/// <param name="ReplaceString">String to be replaced.</param>
public void ReplaceValue(int RowNum, int ColNum,string ReplaceString)
{
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
int m_intColPos = -1;
if (CheckNumericColumn(ColNum, ref m_intColPos))
{
clsTxtBox.TypeEnum objEnum = (clsTxtBox.TypeEnum)arlNumericColumnType[m_intColPos];
if (objEnum == clsTxtBox.TypeEnum.Float)
{
#region Float
if (ReplaceString == "")
ReplaceString = "0";
int m_intPrecision = (int)arlNumericColFloatSize[m_intColPos];
Decimal m_decTemp = Math.Round(Convert.ToDecimal(ReplaceString, nmfi), m_intPrecision);
string m_strTemp = "0", m_strLocal = nmfi.NumberDecimalSeparator;
for (int k = 0; k < m_intPrecision; k++)
m_strLocal += "0";
m_strTemp += m_strLocal;
//string rep = m_decTemp.ToString("###" + m_strTemp + ";",nmfi); //###" + m_strTemp + ";"+ m_strLocal);
string rep = m_decTemp.ToString(nmfi); //###" + m_strTemp + ";"+ m_strLocal);
//int ind = ReplaceString.LastIndexOf(".");//Change On 19/1/2007
int ind = ReplaceString.LastIndexOf(nmfi.NumberDecimalSeparator);
if (ind < 0)
{
}
else
{
string originalIntPortion = ReplaceString.Substring(0, ind);
if (originalIntPortion == "") originalIntPortion = "0";
string nextIntPortion = rep.Substring(0, rep.LastIndexOf(nmfi.NumberDecimalSeparator));
if (nextIntPortion == "") nextIntPortion = "0";
rep = rep.Replace(nextIntPortion, originalIntPortion);
}
dvSource[RowNum][ColNum] = rep;
#endregion
}
else
{
dvSource[RowNum][ColNum] = ReplaceString;
}
}
else
{
dvSource[RowNum][ColNum] = ReplaceString;
}
dvSource.Table.AcceptChanges();
this.Refresh();
}
示例12: ReplaceInReadOnlyColumn
public void ReplaceInReadOnlyColumn(int RowNum, int ColNum, string ReplaceString)
{
//this.CurrentCell = new DataGridCell(RowNum,ColNum); // Infinite Loop
CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name, true);
NumberFormatInfo nmfi = new NumberFormatInfo();
nmfi = ci.NumberFormat;
ci.ClearCachedData();
this.CurrentRowIndex = RowNum;
_colReplacing = ColNum;
int m_intColPos = -1;
if (CheckNumericColumn(ColNum, ref m_intColPos))
{
string rep = "";
clsTxtBox.TypeEnum objEnum = (clsTxtBox.TypeEnum)arlNumericColumnType[m_intColPos];
if (objEnum == clsTxtBox.TypeEnum.Float)
{
if (ReplaceString == "")
ReplaceString = "0";
int m_intPrecision = (int)arlNumericColFloatSize[m_intColPos];
Decimal m_decTemp = Math.Round(Convert.ToDecimal(ReplaceString, nmfi), m_intPrecision);
string m_strTemp = "0", m_strLocal = nmfi.NumberDecimalSeparator;
for (int k = 0; k < m_intPrecision; k++)
m_strLocal += "0";
m_strTemp += m_strLocal;
rep = m_decTemp.ToString(nmfi);
int ind = ReplaceString.LastIndexOf(nmfi.NumberDecimalSeparator);
if (ind < 0)
{
}
else
{
string originalIntPortion = ReplaceString.Substring(0, ind);
if (originalIntPortion == "") originalIntPortion = "0";
string nextIntPortion = rep.Substring(0, rep.LastIndexOf(nmfi.NumberDecimalSeparator));
if (nextIntPortion == "") nextIntPortion = "0";
rep = rep.Replace(nextIntPortion, originalIntPortion);
}
}
else
rep = ReplaceString;
MyGridTextBoxColumn objGridTextCol = (MyGridTextBoxColumn)this.TableStyles[0].GridColumnStyles[ColNum];
//objGridTextCol.KeyTextBox.Modified=true;
//objGridTextCol.KeyTextBox.TextChanged -= new EventHandler(TextBox_TextChanged);
objGridTextCol.KeyTextBox.Text = rep;
dvSource[RowNum][ColNum] = rep;
//objGridTextCol.KeyTextBox.TextChanged += new EventHandler(TextBox_TextChanged);
}
else if (CheckComboBoxColumn(ColNum, ref m_intColPos))
{
DataGridComboBoxColumn objGridComboCol = (DataGridComboBoxColumn)this.TableStyles[0].GridColumnStyles[ColNum];
//objGridComboCol.TextBox.Modified = true;
//objGridComboCol.TextBox.TextChanged+=new EventHandler(TextBox_TextChanged);
//objGridComboCol.TextBox.Text = ReplaceString;
objGridComboCol.ColumnComboBox.Text = ReplaceString;
dvSource[RowNum][ColNum] = ReplaceString;
}
else if (CheckDateTimeColumn(ColNum, ref m_intColPos))
{
DataGridDateTimePicker objGridDTPCol = (DataGridDateTimePicker)this.TableStyles[0].GridColumnStyles[ColNum];
//objGridDTPCol.TextBox.Modified = true;
//objGridDTPCol.TextBox.TextChanged += new EventHandler(TextBox_TextChanged);
//objGridDTPCol.TextBox.Text = ReplaceString;
objGridDTPCol.ColumnDateTimePicker.Text = ReplaceString;
dvSource[RowNum][ColNum] = ReplaceString;
}
else
{
MyGridTextBoxColumn objGridTextCol = (MyGridTextBoxColumn)this.TableStyles[0].GridColumnStyles[ColNum];
//objGridTextCol.TextBox.Modified=true;
//objGridTextCol.TextBox.Text = ReplaceString; //Added - 11/03/2006 - Indranil
//objGridTextCol.KeyTextBox.TextChanged -= new EventHandler(TextBox_TextChanged);
//objGridTextCol.TextBox.Text = ReplaceString;
objGridTextCol.KeyTextBox.Text = ReplaceString;
dvSource[RowNum][ColNum] = ReplaceString;
//objGridTextCol.KeyTextBox.TextChanged += new EventHandler(TextBox_TextChanged);
}
_colReplacing = -1;
this.SetRowStatus(RowNum);
this.SetTxtChange();
dvSource.Table.AcceptChanges();
this.Refresh();
}