Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# DataGridView WinForm
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)
                    {
 
                    }
                }
            }
        }
 
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
Posted 16-Sep-12 20:29pm
VIPR@T2.8K
Edited 16-Sep-12 20:31pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
Comments
VIPR@T at 17-Sep-12 1:41am
   
I had check using MessageBox is well. This Event is going to call. But not giving me desired out put. If u put debug point and check then its working. I had tried with key_down event is well. But the same problem.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 DamithSL 445
1 Maciej Los 238
2 OriginalGriff 229
3 Zoltán Zörgő 190
4 BillWoodruff 120
0 OriginalGriff 7,969
1 DamithSL 6,139
2 Sergey Alexandrovich Kryukov 5,449
3 Maciej Los 5,309
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 17 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100