Link to home
Start Free TrialLog in
Avatar of tlatacki
tlatacki

asked on

Locking user into a DataGrid if column totals are incorrect.


I'm having an issue keeping the user from leaving a data grid if certain criteria isn't met.

I'm able to the checking on the validating event of the datagrid.

I'm having the problem if the user clicks on either a button or menu option on the parent form.
I'm not able to stop the event from executing even though I'm trapping and displaying my message.

Avatar of RobertRFreeman
RobertRFreeman
Flag of United States of America image

You should use the dataset's columnChanging event.  You can check the proposedvalue, then set the columnerror to track changes in the dataset and display errors in the grid.
If you want to keep them on the grid if there are errors, you can disable the other controls in either event.
i.e. if there is an error, set the columnerror and disable the controls, else set the columnerror = "" and enable the controls.
ASKER CERTIFIED SOLUTION
Avatar of eozz_2000
eozz_2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tlatacki
tlatacki

ASKER

eozz - Works for events on the child. But events (Menu/Toolbar) are still ran.

Robert - I'm trying to see how to disable the Items on the Menu (I think I've found) - but, I haven't found the Toolbar items.

FYI - I inherited this project, so I'm also still trying to understand its functions and use.
The toolbar can be disabled by referencing the toolbar on the form.
Click on the toolbar and look at the properties window to get the name.

Then just use the following:
ToolbarName.Enabled = false

I just don't see it.

I have to use
Me.MdiParent.Menu.MenuItems(0).Enabled = False  
to access the MenuItems - But they don't change right away.

But i can't seem to locate the ToolBar

I haven't done much programming with Parent / Child Forms either.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial