Datagridview事件不会调用 [英] Datagridview Events not going to call

查看:82
本文介绍了Datagridview事件不会调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,

我遇到一个奇怪的问题.
我有如下代码.

Hello Friends,

I am getting one strange problem.
I have code like below.

private void tsTxtSearch_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (tsTxtSearch.Text != "")
            {
                if (e.KeyChar == (char)Keys.Enter)
                {
                    try
                    {
                        GridUtitlity.strFind = tsTxtSearch.Text.Trim();
                        frmReviewSummary.lstFindRef.DataSource = null;
                        rowIndex = 0;
                        roles.Clear();
                        
                        List<int[]> listSMS = GetSearchArrayFromGrid(frmReviewSummary.dgSMS);
                        frmReviewSummary.dgSMS.DataSource = GridUtitlity.dtSMS;
                        frmReviewSummary.dgSMS.CellPainting += new DataGridViewCellPaintingEventHandler(dgSMS_CellPainting);
                        
                        frmReviewSummary.lstFindRef.DataSource = roles;
                        frmReviewSummary.lstFindRef.DisplayMember = "Name";
                        frmReviewSummary.lstFindRef.ValueMember = "Id";
                        frmReviewSummary.contFindref.Show(frmReviewSummary.dockPanel1);
                        frmReviewSummary.contFindref.DockState = DockState.DockBottom;
                        frmReviewSummary.contFindref.Focus();
                    }
                    catch (Exception ex)
                    {

                    }
                }
            }
        }



当我使用调试器检查时,此代码工作正常.但是,当我删除调试点时,它不起作用.我不明白发生了什么事.如果我保留调试点,则其工作正常,如果我删除调试点,则其不工作.
有人可以帮忙吗?

谢谢,
Viprat



This code is working in fine when i check using debugger. But when i remove my debug point its not working. i am not getting what happening. If i keep debug point then its working fine and if i remove the debug point its not working.
Can any one please help in this?

Thanks,
Viprat

推荐答案

提出问题的正确方法.
在内部try块中添加MessageBox 并检查而不放置断点.调试器是否进入内部.清理并重建您的解决方案.
试试这个:
Right way of asking question.
Add a MessageBox inside try block and check without putting a break-point. Whether the debugger is coming inside or not. Clean and rebuild your solution.
Try this:
try
{
    GridUtitlity.strFind = tsTxtSearch.Text.Trim();
    MessageBox.Show("Hello");
    /*
     *  Your code goes here
     */
}



--Amit



--Amit




这种行为的可能性是,

您正在调用一些尚未完成的长期运行的Thread函数,并且正在尝试获取该线程更新的值.在这种情况下,调试将起作用,因为下一行执行之间会有延迟.要检查此类问题,您需要添加一些 Thread.Sleep .

我在您的代码中找到了这样的地方.显示 listSMS计数的消息(如_Amy在Solution1中一样).如果给出正确的结果,则寻找您的其他代码.
Hi,

Possiblity of this behavior is,

You are calling some long running Thread function that is not yet completed and You are trying to get the value updated by that thread. In such scenario debug will work as there is delay between next line execution. To check such issue, you need to add some Thread.Sleep.

I found such a place in your code. Display the message of listSMS count(As in Solution1 by _Amy). If it gives the correct result then look for your other code.


这篇关于Datagridview事件不会调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆