Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 24th, 2012  |  syntax: None  |  size: 4.37 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Operation is not valid because it results in a reentrant call to the SetCurrentCellAddressCore function
  2. if (dgv_Panchang.CurrentCell.ColumnIndex == 1)
  3.         {
  4.             if (cmbBox == null) { return; }
  5.             else
  6.             {
  7.                 cmbBox.SelectedIndexChanged += new EventHandler(cmbBox_SelectedIndexChanged);                
  8.             }
  9.         }
  10.         else if (dgv_Panchang.CurrentCell.ColumnIndex == 4)
  11.         {
  12.            cmbBox.SelectedIndexChanged -= new EventHandler(cmbBox_SelectedIndexChanged);
  13.            cmbBox.SelectedIndexChanged += new EventHandler(cmbBox_SelectedIndexChanged);              
  14.         }
  15.     }
  16.  
  17.     private void cmbBox_SelectedIndexChanged(object sender, EventArgs e)
  18.     {
  19.         try
  20.         {
  21.             // dgv_Panchang.EndEdit();
  22.             string SpID = string.Empty;
  23.             //ComboBox cmbBox = (ComboBox)sender;
  24.             ComboBox cmbBox = new ComboBox();
  25.             cmbBox = (ComboBox)sender;
  26.             if (cmbBox != null)
  27.             {
  28.  
  29.                 if (dgv_Panchang.CurrentCell.ColumnIndex == 1)
  30.                 {
  31.  
  32.  
  33.                     Cls_Global_Var.Name = string.Empty;
  34.                     Cls_Global_Var.Name = cmbBox.SelectedItem.ToString();
  35.                     if (Cls_Global_Var.Name != string.Empty)
  36.                     {
  37.                         Cls_Global_Var.StrSql = string.Empty;
  38.                         Cls_Global_Var.StrSql = "select Pk_SpecialDay from  tbl_specialday where V_Title ='" + Cls_Global_Var.Name + "'";
  39.  
  40.                         SpID = Cls_DataBase.GetIdentCurrentID(Cls_Global_Var.StrSql);
  41.  
  42.                         if (SpID != null)
  43.                         {
  44.                             int RowIndex = dgv_Panchang.CurrentCell.RowIndex;
  45.                             int ColIndex = dgv_Panchang.CurrentCell.ColumnIndex;
  46.                             DataGridViewCell dgvCurrent = dgv_Panchang[ColIndex + 2, RowIndex];
  47.                             if (dgvCurrent != null)
  48.                             {
  49.                                 dgv_Panchang.CurrentCell = dgvCurrent;
  50.                                 dgv_Panchang.CurrentRow.Cells["SPDValue"].Value = SpID;
  51.  
  52.                                 Cls_PanchangMaster_Obj.GetSpecialDayName(Convert.ToInt32(SpID), ColIndex, dgv_Panchang);
  53.                             }
  54.  
  55.                         }
  56.                     }
  57.                     else
  58.                     {
  59.                         return;
  60.                     }
  61.                 }
  62.                 else if (dgv_Panchang.CurrentCell.ColumnIndex == 4)
  63.                 {
  64.                     //try
  65.                     //{
  66.  
  67.                         Cls_Global_Var.Name = string.Empty;
  68.                         Cls_Global_Var.Name = cmbBox.SelectedItem.ToString();
  69.                         if (Cls_Global_Var.Name != string.Empty && Cls_Global_Var.Name != null)
  70.                         {
  71.                             Cls_Global_Var.StrSql = string.Empty;
  72.                             Cls_Global_Var.StrSql = "select Pk_SpecialDay from  tbl_specialday where V_Title ='" + Cls_Global_Var.Name + "'";
  73.  
  74.                             SpID = Cls_DataBase.GetIdentCurrentID(Cls_Global_Var.StrSql);
  75.                             if (SpID != null)
  76.                             {
  77.                                 int RowIndex = dgv_Panchang.CurrentCell.RowIndex;
  78.                                 int ColIndex = dgv_Panchang.CurrentCell.ColumnIndex;
  79.                                 DataGridViewCell dgvCurrent = dgv_Panchang[ColIndex + 2, RowIndex];
  80.                                 if (dgvCurrent != null)
  81.                                 {
  82.                                     dgv_Panchang.CurrentCell = dgvCurrent;
  83.                                     dgv_Panchang.CurrentRow.Cells["SPDValue"].Value = SpID;
  84.  
  85.                                     Cls_PanchangMaster_Obj.GetSpecialDayName(Convert.ToInt32(SpID), ColIndex, dgv_Panchang);
  86.                                 }
  87.  
  88.                             }
  89.                         }
  90.                     //}
  91.                     //catch (Exception ex)
  92.                     //{
  93.                     //    Cls_GlobalMessage.CreatErrorLog(ex.Message.ToString());
  94.                     //}
  95.                 }
  96.             }
  97.         }
  98.         catch (Exception ex)
  99.         {
  100.             Cls_GlobalMessage.CreatErrorLog(ex.Message.ToString());
  101.         }
  102.         finally
  103.         {
  104.             dgv_Panchang.ClearSelection();
  105.             dgv_Panchang.EndEdit();
  106.         }
  107.     }