int valuetxtbox1 = convert.ToInt(textbox1.text);
int valuetxtbox2 = convert.ToInt(textbox2.text);
foreach(Datarow dr in dtData.rows)
{
int a = convert.ToInt(dr["Data1"] .Tostring());
int b = convert.ToInt(dr["Data2"] .Tostring());
dr["Data1"] = a*valuetxtbox1;
dr["Data2"] = a*valuetxtbox2;
}
dtData.AcceptChanges();//เมื่อมีการเปลี่ยนข้อมูลใช้
//1st Loop for find max value of column
for (int i = 0; i < dt.Rows.Count; i++)
{
if (valueA < Convert.ToDouble(dt.Rows[i][0]))
{
valueA = Convert.ToDouble(dt.Rows[i][0]);
}
if (valueB < Convert.ToDouble(dt.Rows[i][1]))
{
valueB = Convert.ToDouble(dt.Rows[i][1]);
}
}
//valueA = max value of column A, indexA = index of max value of column A
//valueB = max value of column B, indexB = index of max value of column B
//dt.Rows[indexA][0] = TextBox1.Text;
//dt.Rows[indexB][1] = TextBox2.Text;
//2nd Loop for replace new value
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i][0] = (Convert.ToDouble(dt.Rows[i][0]) / valueA) * Convert.ToDouble(TextBox1.Text);