Expand|Select|Wrap|Line Numbers
- // initialize varaibles from dataGridView
- double C1;
- double INF1;
- double T1;
- //Read String values from each dataGridView Cell
- String^C1s = safe_cast<String^>(dataGridView1[0,0]->Value);
- String^INF1s = safe_cast<String^>(dataGridView1[0,1]->Value);
- String^T1s = safe_cast<String^>(dataGridView1[0,2]->Value);
- //Convert from String Value to Double
- C1 = Convert::ToDouble(C1s);
- INF1 = Convert::ToDouble(INF1s);
- T1 = Convert::ToDouble(T1s);
"An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll Additional information: Index was out of range. Must be non-negative and less than the size of the collection."
I have added following code to form to restrict number of rows as defined in numericupdown box
Expand|Select|Wrap|Line Numbers
- private: System::Void dataGridView1_RowEnter(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e) //raises event handler
- {
- int NUMST;
- NUMST = safe_cast<int>(this->numericUpDown1->Value); //Input from numericUpDown box
- if (this->dataGridView1->RowCount > NUMST)
- this->dataGridView1->AllowUserToAddRows = false;
- }
Would anybody have a suggestion on how to make this work, or is there a better way to read data from unboubnd datagrid and assign each cell to double numeric variable to be used in function? Thank you.