Results 1 to 2 of 2

Thread: How to customize MS DataGrid Control canceled message box?

  1. #1

    Thread Starter
    Addicted Member kutlesh's Avatar
    Join Date
    Jun 2018
    Location
    Skopje, Macedonia
    Posts
    202

    How to customize MS DataGrid Control canceled message box?

    How can i customize the MS DataGrid Control 6.0 canceled action message box?

    Name:  USP_DataGrid.png
Views: 202
Size:  9.9 KB

    For example can I add a custom message instead of just showing "Action is canceled"?

    Note: This is a message box that appears when you set Cancel = True to a for example BeforeUpdate event on a DataGrid, like so:

    Code:
    Private Sub DataGrid1_BeforeUpdate(Cancel As Integer)
        Cancel = validateMyData(CStr(DataGrid1.Columns(1).Value))
    
        ' If Cancel = -1(True), the message box is displayed saying cannot progress to 
        ' different row if the data is not corrected
        ' if Cancel = 0(False), i can freely move other row.
    End Sub
    Last edited by kutlesh; Dec 4th, 2019 at 06:58 AM.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: How to customize MS DataGrid Control canceled message box?

    Replacing a modal dialog displayed by an external control isn't that easy, but not too difficult either. I think the most common method when you know a dialog will be displayed is:

    1. Create a CBT hook that looks for newly created dialog windows
    2. Allow the event to do the cancel action
    3. The CBT hook catches the dialog window and you prevent it from being created/displayed
    4. Remove the CBT hook
    5. Display your own message box

    Note: if the datagrid supports multiple languages, you can lose the advantage of displaying the message in the user's language

    CBT hook examples exist on this forum. Here is documentation regarding hooks in general
    https://docs.microsoft.com/en-us/win...sg/about-hooks
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width