DataGridView Cell Format
-
I use Visual c++ Net 2005 I have in my DataGridView one Column 'quantite'. In this column I need to put only numbers. How can I format this column sothat I can only capture numbers ?
This kinda goes along with my answer to your previous question.[^]. There is no "DataGridViewMaskedTextBoxCell" available so you will need to get the cell that the user just modified and format/validate the value yourself.
Don't be overcome by evil, but overcome evil with good
-
This kinda goes along with my answer to your previous question.[^]. There is no "DataGridViewMaskedTextBoxCell" available so you will need to get the cell that the user just modified and format/validate the value yourself.
Don't be overcome by evil, but overcome evil with good
System::Void grid_CellValidating(System::Object^ sender, System::Windows::Forms::DataGridViewCellValidatingEventArgs^ e) { bool bInt = false; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) if(!wchar_t::IsDigit(ch)) bInt = true; if(e-->ColumnIndex==2)//Quantity { if(bInt) ;//DO else return; } }
Nigah M Manzoor
-
System::Void grid_CellValidating(System::Object^ sender, System::Windows::Forms::DataGridViewCellValidatingEventArgs^ e) { bool bInt = false; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) if(!wchar_t::IsDigit(ch)) bInt = true; if(e-->ColumnIndex==2)//Quantity { if(bInt) ;//DO else return; } }
Nigah M Manzoor
-
for float type variable : bool bFloat = false; int i = 0; for each (wchar_t ch in e->FormattedValue->ToString()->Trim()) { if(!wchar_t::IsDigit(ch)) { if(ch=='.' && i == 0) { bFloat = false; i++; } else bFloat = true; } }
Nigah M Manzoor