Solved

Locking user into a DataGrid if column totals are incorrect.

Posted on 2004-10-11
7
222 Views
Last Modified: 2010-04-24

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.

0
Comment
Question by:tlatacki
  • 4
  • 2
7 Comments
 
LVL 16

Expert Comment

by:RobertRFreeman
Comment Utility
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.
0
 
LVL 16

Expert Comment

by:RobertRFreeman
Comment Utility
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.
0
 
LVL 4

Accepted Solution

by:
eozz_2000 earned 20 total points
Comment Utility
   Private Sub DataGrid1_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles DataGrid1.Validating
        MsgBox("Validating")
        e.Cancel = True
        Me.DataGrid1.Select()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("Hello")
    End Sub

I use the Validating event of dataGrid to cancel the events of other controls, with:

e.Cancel = True
me.DataGrid1.Select()
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:tlatacki
Comment Utility
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.
0
 
LVL 16

Expert Comment

by:RobertRFreeman
Comment Utility
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
0
 

Author Comment

by:tlatacki
Comment Utility

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.
0
 
LVL 16

Assisted Solution

by:RobertRFreeman
RobertRFreeman earned 180 total points
Comment Utility
Ok, then that's a different story.  You'll just need to type the mdiParent as its class name.

So let's say your parent form with the toolbar is named MyMainForm.

Then you'd use:

ctype(me.mdiparent, MyMainForm).ToolBarName.Enabled = false
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now