none
Handle commandbar combobox onclick/focus textbox RRS feed

  • Question

  • I am creating a commandbarcombobox and make it appear like a textbox. The combobox has prefilled text="Search". What I want is that as soon as I bring my focus on the combobox or I click on the combobox, then the prefilled text should automatically get cleared without the user explicitly clearing the text using "Delete button".Can we create some event to handle this?An action similar to this can be seen on the "Search address books" control available in Outlook.Could you please help me out with this as this is an urgent requirement for my project?
    I am posting my code to create a commandbar combobox here:-
     

    Office.CommandBar _objTmpToolBar = (Office.CommandBar)this.Application.ActiveExplorer().CommandBars.FindControl(missing, missing, menuToolBarTag, true);
    if (_objTmpToolBar != null)
    _objTmpToolBar.Delete();
    // Add a new toolbar to the CommandBars collection of the Explorer window
    mycmdbar = applicationobject.ActiveExplorer().CommandBars.Add(menuToolBarTag, Office.MsoBarPosition.msoBarTop, false, true);
    mycmdbar.Visible = true;
    mycmdbar.Enabled = true;
     
    if (mycmdbar != null)
    {
    // Add a combobox to the new toolbar

    cmbbox = (Office.CommandBarComboBox)mycmdbar.Controls.Add(Office.MsoControlType.msoControlEdit, Type.Missing, Type.Missing, Type.Missing, false);
     
    cmbbox.Style = Office.MsoComboStyle.msoComboNormal;
    cmbbox.Enabled = true;
    cmbbox.Width = 200;
    cmbbox.Text = "Search";
     
    cmbbox.Change += new Office._CommandBarComboBoxEvents_ChangeEventHandler(cmbbox_Change);
    }

    cmbbox.Change += new Office._CommandBarComboBoxEvents_ChangeEventHandler(cmbbox_Change);
     
    When user enters the search criteria text in search textbox and presses enter,then the change event gets fired. The change events shows results corresponding to the entered criteria
     
    private void cmbbox_Change(Office.CommandBarComboBox ctrl)
    { 
    ProcessStartInfo sinfo = new ProcessStartInfo("http://localhost/MySearch/?id=" + searchcriteria);
    Process.Start(sinfo);
    }
    Tuesday, May 28, 2013 10:39 AM

All replies

  • Hi Ridhika,

    Thank you for posting in the MSDN Forum.

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards,


    Quist Zhang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, May 30, 2013 12:55 PM
    Moderator
  • Hi Quist Zhang,

    Thanks for your reply! Could you please get it resolved asap as this is hampering the progress of my project. Looking forward to hear from you very soon!

    Regards

    Ridhika


    • Edited by Ridhika Friday, May 31, 2013 5:40 AM
    Friday, May 31, 2013 5:40 AM