?
Solved

Locking user into a DataGrid if column totals are incorrect.

Posted on 2004-10-11
7
Medium Priority
?
230 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
[X]
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
  • 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 80 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 720 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 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