1. 程式人生 > >GrapeCity的Combo事件:奇怪的SelectedIndexChanged

GrapeCity的Combo事件:奇怪的SelectedIndexChanged

cmbHaitatubin,cmbShukkasoko,Combo3
  private void cmbShukkasoko_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   if( -1 == cmbShukkasoko.SelectedIndex )
   {
    clsFormFunction.ComboClear( cmbHaitatubin );
    return;
   }

   string strBushoSokoCode = clsFormFunction.GetComboCD( cmbShukkasoko );

   HaitatubinGet( strBushoSokoCode, ref strMsg );
  }

  private int HaitatubinGet( string strBushoSokoCode, ref string strMsg )
  {
   。。。。。。。。
   intRet = CMPSpKick( strSPName, dtsInParam, ref dtsOutParam, ref dtsHaisouBin );

   if( intRet != 0 )
   {
    strMsg = OutParamGet( dtsOutParam.Tables[0], "@o_ERRMSG" );
    return intRet;
   }

   string strDefault = OutParamGet( dtsOutParam.Tables[0], "@o_CmbDefValue" );
   clsFormFunction.ComboDataSetMake( ref dtsCmb, dtsHaisouBin.Tables[0], "BIN", "HAISO_ROOT_MJ" );   
   clsFormFunction.ComboBind( cmbHaitatubin, dtsCmb );
   clsFormFunction.ComboSelect( cmbHaitatubin, strDefault );

   clsFormFunction.SetComboPixWidth( cmbHaitatubin );
   cmbHaitatubin.SelectionStart = 0;
   cmbHaitatubin.SelectionLength = 0;

   return 0;
  }

//cmbHaitatubin,cmbShukkasoko,Combo3's Leave event
  private void combo_FocusLosted(object sender, System.EventArgs e)
  {
   FormFunction clsFormFunction = new FormFunction();
   clsFormFunction.combo_FocusLosted( sender );

   switch (((Control)sender).Name)
   {
    case "cmbShukkasoko":
     if( cmbShukkasoko.SelectedIndex == -1 )
     {
      clsFormFunction.ComboClear( cmbHaitatubin );
      return;
     }
     break;
   }
  }
現象:1 cmbShukkasoko的text是All items text一部分時,click Combo3, cmbShukkasoko不能自動選擇匹配的Item,但
click文字控制元件(非Combo)時正常(能自動選擇匹配的Item)。
2 cmbShukkasoko的SelectedIndexChanged時,
cmbHaitatubin不能自動選擇某一項。
*****I 服了GrapeCity.Win.Input ..........

答:在另一個事件combo_TextChanging裡,使用了GrapeCity提供的Combo.FindString( ... ),該函式在某些情況不能
檢索出對應的Item。結果每次設定SelectedIndex 時,Combo.Text改變,但combo_TextChanging裡的Combo.FindString( ... )檢索不出,導致e.Cancel = true。

GrapeCity, I fu le u .