Is the following possible in a Datagrid/Dataset?

Okay They are wanting me to have a datagrid that shows data from a particular table... There is a column in the table called wasMailed... it holds true or false. The datagrid displays this as a checkbox.

here is the tough part...
Any row that has a checkbox checked in the datagrid needs to be read-only, but the actual checkbox itself needs to be editable... So some rows will be read-only (depending on the check value) and some will not, but the wasMailed column will never be read-only...

Can that be done? (I'm sure it can, i'm just not quite sure how)
LVL 6
PoeticAudioAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ready1Commented:
if you are using the stock grid from VS then you have no chance of getting this done.

Basically what needs to happen is:

* you will need to capture the on cell edit of the gridrow and if the checkbox is ticked then cancel the event UNLESS the cell being edited is the cell containing the checkbox.

Regards,
Ready1
sumixCommented:

 One way to solve this is creating a handler for CurrentCellChanged event of the Datagrid and check the value of the wasMailed column in the current row. If it is true, make all the DataGridColumns read only, something like:

dgr.CurrentCellChanged +=new EventHandler(dgr_CurrentCellChanged);

private void dgr_CurrentCellChanged(object sender, EventArgs e)
{
    if (Convert.ToBoolean(dgr[dgr.CurrentRowIndex,0]))
      columnX.ReadOnly = true;
                // and any other columns you need to make read only
    else
      columnX.ReadOnly = false;
}

 A note regarding this approach is that you have to explicitly define the tablestyle of the datagrid and the columns in its collection. This is because you need to have access to datagrid columns.
But the solutions is easy and it works.

regards,
sumix

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.