Hello to all. Such a problem:

There is a DataGridView. It displays information from the database table. There are also two buttons Add and Remove, from the name it is clear what they are doing.

I need to make it so that I forbid the user to use the Remove button on those rows that were previously listed in the table, before opening the program. The Remove button should be available only for those lines that were added during program execution; as soon as I closed and re-opened it, the Remove button became unavailable for those lines.

In principle, the problem is elementary, but I would like to make it more advanced. As expected, so to speak. At this time, I have a table, in each row of the table there is a root field, which gives the right of the Remove button to be unlocked or locked. But I would like, of course, to get rid of this field, and do it in a normal way.

There were also thoughts to check the status of the DataRow row, and if it is a DataRowState.Added, then unlock the button, otherwise not ... but something didn’t work out for me with this ...

Somebody knows?

  • You are asking to improve, but you are not presented with your solution, which needs to be made better. Therefore, having come to you at the light, the enlightened public shrugs in surprise and wanders further on. IMHO, to keep the sign in the database and make a decision about access to the buttons on it is a normal decision. What is the problem? - Alexander Muksimov
  • IMHO, DataRowState is better not to touch, it serves for another - Alexander Muksimov
  • If I keep the line access attribute in the database - is this normal? Well, you did not immediately say! I did this before, and everything worked :) Thank you, then I will leave it like this - Bretbas

0