none
Button click event not raised after that DataGridView cell validation

    Question

  • Currently, I am facing the issue while implementing the cellvalidation for datagridview. Please refer the below attached and replication procedure to reproduce the issue,

     

    Replication procedure:

    1. Run the attached sample.

    2. Delete the any cell value in Id column.

    3. Click the tabpage2

    4. Message box appears to enter the valid value.

    5. press ok button. Then, enter the valid value in that cell.

    6. Click on the button1

    Issue:

    Button1 click event has not raised.

     

     Sample link: https://1drv.ms/u/s!AieEPKCxZLyJ0ixXtuCKuiOf8dtL

     Video demo: https://drive.google.com/open?id=1Me0VEvtrWZz8PkNnUPwVxuVzwLN6EBh2  

     

    Please let me know anything missed in my sample.

     

    Thanks,


    Mohanraj G





    • Moved by CoolDadTxMVP Wednesday, February 7, 2018 3:35 PM Winforms related
    • Edited by Mohanmj Thursday, February 8, 2018 10:30 AM
    Wednesday, February 7, 2018 7:34 AM

All replies

  • I assume there are few who open your kind of link in 2018

    If you want this, than place it on something like "one drive" as a zip file. 


    Success Cor

    Wednesday, February 7, 2018 8:10 AM
  • I have uploaded my sample in one drive and updated the sample link in above post.

    Can you please check and suggest me your solution.

    Thanks,


    Mohanraj G


    • Edited by Mohanmj Wednesday, February 7, 2018 4:40 PM
    Wednesday, February 7, 2018 4:39 PM
  • I deleted a value in id which means "Enter a value" is displayed, so I have to enter a value and do so. Click on tab2, click on tab1, Could not reproduce your issue.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, February 8, 2018 12:12 AM
    Moderator
  • Hi karen,

    Thanks for your update.

    Can you please follow my replication procedure to reproduce the issue. Delete the value in id column then press the tabpage2.

    Also, i have attached the video demo for your reference. Please refer the above attached video demo.

    Please let me know if you have any other queries.

    Thanks,


    Mohanraj G

    Thursday, February 8, 2018 12:51 PM
  • Hi karen,

    Thanks for your update.

    Can you please follow my replication procedure to reproduce the issue. Delete the value in id column then press the tabpage2.

    Also, i have attached the video demo for your reference. Please refer the above attached video demo.

    Please let me know if you have any other queries.

    Thanks,


    Mohanraj G

    Well if I delete the value in the id column I can't continue as it is required as per your logic thus I can't go to tab 2. I did exactly as you did after watching the video and button1 works.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Thursday, February 8, 2018 3:44 PM
    Moderator
  • Hi Karen, I don't know how it works to you. I have tested this sample in framework 4.5.1,4.6. This issue is reproducing in all tested machines. I think you are missing something in my replication procedure to reproduce the issue. Thanks,

    Mohanraj G

    Thursday, February 8, 2018 6:33 PM
  • Hi Mohanmj,

    That is because you used the e.Cancel=true in your code:

            private void DataGridView2_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
            {
                string text = e.FormattedValue.ToString();
                if (string.IsNullOrEmpty(text))
                {
                    MessageBox.Show("Enter the value");
                    e.Cancel = true;
                }
            }

    If you comment out this line, then the problem will not happen again, Please check it.

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, February 12, 2018 6:53 AM
    Moderator
  • Hi @Frankie,

    Thanks for your suggestion.

    Actually, i want to enable the validation for Id column when cell has an empty value.

    My query: If i delete the value in Id column then press the tab page2, message will be appeared with "Enter the valid value" which is fine.

    Then enter the valid value for that column, cell validation is success. But, if i press the button, button click event has not raised.

    Why the button click event has not raised after pressing the tab page.

    Thanks,

     


    Mohanraj G

    Monday, February 12, 2018 6:41 PM
  • Hi,

    Please help me. If any one know the solution to resolve this issue.

    Thanks,


    Mohanraj G


    • Edited by Mohanmj Tuesday, February 27, 2018 8:30 AM
    Tuesday, February 27, 2018 7:32 AM
  • Hi Mohanmj,

    I tested it a lot and I can not find a valid evidence for this strange phenomenon, maybe it is a bug, I suggest you connect Microsoft for this problem.

    Regards,

    Frankie


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, February 28, 2018 1:34 AM
    Moderator