Results 1 to 4 of 4

Thread: [RESOLVED] DatagridView TextBoxColumn Autosuggest

  1. #1

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Resolved [RESOLVED] DatagridView TextBoxColumn Autosuggest

    Hi all,
    I am using this method to set the AutoSuggest for the TextBox Column in Gridview. But it is not showing the list during typing ?

    PHP Code:
     private void GridView_EditingControlShowing(object senderDataGridViewEditingControlShowingEventArgs e)
            {
               
    string  Role =e.Control.AccessibilityObject.Role.ToString();
               switch (
    Role)
                {
                    case  
    "ComboBox":
                        
    ComboBox cbo e.Control as ComboBox;
                        
                        break;

                    case 
    "Text":

                        if (
    _CurrentCellColumnIndex == 0)
                        {
                            
    TextBox txt e.Control as TextBox;
                            if (
    txt != null)
                            {
                                
    //txt.AutoCompleteMode = AutoCompleteMode.Suggest;
                             // private string[] _ModuleAutoCompleteSuggestion; //Declared in FormLevel
                                
    Array.Sort(_ModuleAutoCompleteSuggestion);
                                
    txt.AutoCompleteCustomSource.Clear();
                                
    txt.AutoCompleteCustomSource.AddRange(_ModuleAutoCompleteSuggestion);
                            }
                        }
                        break;

                } 
    Please mark you thread resolved using the Thread Tools as shown

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: DatagridView TextBoxColumn Autosuggest

    wouldn't that be:

    Code:
    // private string[] _ModuleAutoCompleteSuggestion; //Declared in FormLevel
    Array.Sort(_ModuleAutoCompleteSuggestion);
    txt.AutoCompleteCustomSource.Clear();
    txt.AutoCompleteCustomSource.AddRange(_ModuleAutoCompleteSuggestion);
    txt.AutoCompleteMode = AutoCompleteMode.Suggest;
    ?

  3. #3

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: DatagridView TextBoxColumn Autosuggest

    Thanks for the reply paul. But is not showing the list as autosuggest?
    Please mark you thread resolved using the Thread Tools as shown

  4. #4

    Thread Starter
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: DatagridView TextBoxColumn Autosuggest

    No issues this worked

    Code:
    if (this.GridView.CurrentCell.ColumnIndex == 0)
                        {
                            TextBox txt = e.Control as TextBox;
                            if (txt != null)
                            {
                                if (_ModuleAutoCompleteSuggestion != null)
                                {
                                    Array.Sort(_ModuleAutoCompleteSuggestion);
                                    txt.AutoCompleteCustomSource.Clear();
                                    txt.AutoCompleteCustomSource.AddRange(_ModuleAutoCompleteSuggestion);
                                    txt.AutoCompleteSource = AutoCompleteSource.CustomSource;
                                    txt.AutoCompleteMode = AutoCompleteMode.Suggest;
                                }
    
                            }
                        }
                        break;
    Please mark you thread resolved using the Thread Tools as shown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width