Search code examples
visual-studio-2013visual-studio-addinscommandbar

How to get user input on click of a CommandBarControl item


I have a CommandBarControl and on the click of this control, I want to get a number as user input.

private void oControlHandler_Click(object CommandBarControl, ref bool Handled, ref bool CancelDefault)
{
//get a number as user input

//do some work on input
}

How to get user input? I am using VS 2013 and .NET framework 4.0.


Solution

  • You need to create a Windows Forms (or WPF) form with a control to enter the input, which can be a TextBox or some kind of NumericUpDown. Then, on the Click event you show the form modally (ShowDialog). Notice that your question is not related to Visual Studio add-ins.