Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Locking user into a DataGrid if column totals are incorrect.

Posted on 2004-10-11
7
226 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
ID: 12281758
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
ID: 12281816
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
ID: 12282200
   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 Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:tlatacki
ID: 12286282
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
ID: 12289750
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
ID: 12290952

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
ID: 12291016
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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