I have a dataset which contains the following tables:
https://i.stack.imgur.com/fZisY.png
As you can see it's possible to edit it's values directly (and i prefer it that way), but sometimes i wanna limit its value, for example, if the user attempts to place a number 3, i want the program to display a message:
MessageBox.Show("This parameter can only use values between 0 and 1.";);
and then proceed to set the value to 1 (which is closest to 3)
is this possible? What is the action that makes the program recognize the value the user has just input?
edit: it's pretty simple, you can use something like this
if (Convert.ToDecimal(dataGridView1.Rows[0].Cells["Columnname"].Value) > 5)
{
MessageBox.Show("The value can't be above 5.");
dataGridView1.Rows[0].Cells["Columnname"].Value = "5";
}
where [0]
is the row number (starts at zero), basically the dataGridView1.Rows[0].Cells["Columnname"].Value
command allows you to control directly a row, and a column value