本文整理汇总了C#中InputBox类的典型用法代码示例。如果您正苦于以下问题:C# InputBox类的具体用法?C# InputBox怎么用?C# InputBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InputBox类属于命名空间,在下文中一共展示了InputBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Show
public static DialogResult Show(string title, string prompt, out string result)
{
InputBox input = new InputBox(title, prompt);
DialogResult retval = input.ShowDialog();
result = input.textInput.Text;
return retval;
}
示例2: Show
public static bool Show(string title, string caption, ref string value, Predicate<string> predicate = null)
{
using (var inputBox = new InputBox())
{
inputBox.Text = title;
inputBox.lciText.Text = caption;
inputBox.lciMemo.Visibility = LayoutVisibility.Never;
inputBox._predicate = predicate;
inputBox.Height = 140;
inputBox.txtMessage.EditValue = value ?? string.Empty;
var dr = inputBox.ShowDialog();
if (dr == DialogResult.OK)
{
value = inputBox.txtMessage.EditValue.ToStringEx();
inputBox._predicate = null;
return true;
}
else
{
value = string.Empty;
inputBox._predicate = null;
return false;
}
}
}
示例3: AskValue
public static string AskValue(IWin32Window owner, string caption = "InputBox", string description = "Insert a new value.", string value = "")
{
InputBox input = new InputBox();
string ret = "";
try
{
input.Text = caption;
input.lbDescription.Text = description;
input.txValue.Text = value;
input.ShowDialog(owner);
if (input.DialogResult == System.Windows.Forms.DialogResult.OK)
{
ret = input.txValue.Text;
}
input.Dispose();
}
catch (Exception ex)
{
MessageBox.Show(ex.GetType().FullName, ex.Message);
}
return ret;
}
示例4: gridMain_CellDoubleClick
private void gridMain_CellDoubleClick(object sender,ODGridClickEventArgs e) {
InputBox editWord=new InputBox("Edit word");
DictCustom origWord=DictCustoms.Listt[e.Row];
editWord.textResult.Text=origWord.WordText;
if(editWord.ShowDialog()!=DialogResult.OK) {
return;
}
if(editWord.textResult.Text==origWord.WordText) {
return;
}
if(editWord.textResult.Text=="") {
DictCustoms.Delete(origWord.DictCustomNum);
DataValid.SetInvalid(InvalidType.DictCustoms);
FillGrid();
return;
}
string newWord=Regex.Replace(editWord.textResult.Text,"[\\s]|[\\p{P}\\p{S}-['-]]","");//don't allow words with spaces or punctuation except ' and - in them
for(int i=0;i<DictCustoms.Listt.Count;i++) {//Make sure it's not already in the custom list
if(DictCustoms.Listt[i].WordText==newWord) {
MsgBox.Show(this,"The word "+newWord+" is already in the custom word list.");
editWord.textResult.Text=origWord.WordText;
return;
}
}
origWord.WordText=newWord;
DictCustoms.Update(origWord);
DataValid.SetInvalid(InvalidType.DictCustoms);
FillGrid();
}
示例5: butAdd_Click
private void butAdd_Click(object sender,EventArgs e) {
if(!Security.IsAuthorized(Permissions.WikiListSetup)) {
return;
}
InputBox inputListName = new InputBox("New List Name");
inputListName.ShowDialog();
if(inputListName.DialogResult!=DialogResult.OK) {
return;
}
//Format input as it would be saved in the database--------------------------------------------
inputListName.textResult.Text=inputListName.textResult.Text.ToLower().Replace(" ","");
//Validate list name---------------------------------------------------------------------------
if(DbHelper.isMySQLReservedWord(inputListName.textResult.Text)) {
//Can become an issue when retrieving column header names.
MsgBox.Show(this,"List name is a reserved word in MySQL.");
return;
}
if(inputListName.textResult.Text=="") {
MsgBox.Show(this,"List name cannot be blank.");
return;
}
if(WikiLists.CheckExists(inputListName.textResult.Text)) {
if(!MsgBox.Show(this,MsgBoxButtons.YesNo,"List already exists with that name. Would you like to edit existing list?")) {
return;
}
}
FormWikiListEdit FormWLE = new FormWikiListEdit();
FormWLE.WikiListCurName = inputListName.textResult.Text;
//FormWLE.IsNew=true;//set within the form.
FormWLE.ShowDialog();
FillList();
}
示例6: CallIBox
/* Brings up the Input Box with the arguments of a */
public Form1.IBArg[] CallIBox(Form1.IBArg[] a)
{
InputBox ib = new InputBox();
ib.Arg = a;
ib.fmHeight = this.Height;
ib.fmWidth = this.Width;
ib.fmLeft = this.Left;
ib.fmTop = this.Top;
ib.TopMost = true;
ib.BackColor = Form1.ncBackColor;
ib.ForeColor = Form1.ncForeColor;
ib.Show();
while (ib.ret == 0)
{
a = ib.Arg;
Application.DoEvents();
}
a = ib.Arg;
if (ib.ret == 1)
return a;
else if (ib.ret == 2)
return null;
return null;
}
示例7: Run
public override void Run()
{
if (this.IsEnabled)
{
InputBox box = new InputBox("请输入使用的远程服务自动升级对象地址:", "提示:", "http://127.0.0.1:7502/RemoteUpdate");
string result = string.Empty;
if (box.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
{
result = box.Result;
if (string.IsNullOrEmpty(result))
{
MessageHelper.ShowInfo("没有输入远程对象地址");
}
else
{
try
{
string remoteLog = (Activator.GetObject(typeof(IRemoteUpdate), result) as IRemoteUpdate).GetRemoteLog();
string path = Path.GetTempFileName() + ".txt";
File.WriteAllText(path, remoteLog);
Process.Start(path);
}
catch (Exception exception)
{
MessageHelper.ShowError("远程服务执行升级操作发生错误", exception);
LoggingService.Error(exception);
}
}
}
}
}
示例8: LoadContent
/// <summary>
/// Load initial game data and assets once.
/// </summary>
public override void LoadContent()
{
//TODO: Offload to initialize
ScreenManager.Game.IsMouseVisible = true;
spriteBatch = ScreenManager.SpriteBatch;
content = new ContentManager(ScreenManager.Game.Services, "Content");
//Load banner Image
//Load Instruction text (also error text)
textMessage = new TextBox(message,
new Vector2(this.ScreenManager.GraphicsDevice.Viewport.Width/2, 290), Color.Black);
textMessage.LoadContent(spriteBatch, ScreenManager.GraphicsDevice,
content);
//Load Input box
inputBox = new InputBox(new Vector2(390, 390), Color.Orange, 10);
inputBox.LoadContent(spriteBatch, ScreenManager.GraphicsDevice, content);
//Load Login Button
loginButton = new Button("Login", new Vector2(390, 500), Color.Aqua);
loginButton.LoadContent(spriteBatch, ScreenManager.GraphicsDevice,
content);
exitButton = new Button("Exit", new Vector2(510, 500), Color.PaleVioletRed);
exitButton.LoadContent(spriteBatch, ScreenManager.GraphicsDevice,
content);
//Load Exit Button
}
示例9: dataGridView1_CellContentClick
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex > -1 && e.RowIndex < dataGridView1.Rows.Count - 1)
{
int.TryParse(dataGridView1.Rows[e.RowIndex].Cells["id"].Value.ToString(), out id);
string imeColumne = dataGridView1.Columns[e.ColumnIndex].Name;
if (imeColumne == "obrisi")
{
if (PrijavljenJe && PristupJe)
{
InputBox frm = new InputBox();
DialogResult rez = frm.ShowDialog();
if (rez == DialogResult.OK)
{
osvjezi = ObrisiMobitel();
GetMobiteli();
}
}
}
else if (imeColumne == "azuriraj")
{
txtImeMobitela.Text = dataGridView1.Rows[e.RowIndex].Cells["ime"].Value.ToString();
tabControl1.SelectedIndex = 1;
}
}
}
示例10: Execute
public void Execute(ICSharpCode.TreeView.SharpTreeNode[] selectedNodes)
{
//Member
var member = (IMemberDefinition)((IMemberTreeNode)selectedNodes[0]).Member;
var rename = GetObjectsToRename(member).ToArray();
//Content of the input box
var content = new StackPanel();
content.Children.Add(new TextBlock() { Inlines = { new Run() { Text = "Insert new name for " }, new Run() { Text = member.Name, FontWeight = System.Windows.FontWeights.Bold }, new Run() { Text = "." } } });
if (rename.Length > 1)
{
content.Children.Add(new TextBlock() { Text = "This action will automatically update the following members:", Margin = new System.Windows.Thickness(0, 3, 0, 0) });
foreach (var x in rename.Skip(1))
content.Children.Add(new TextBlock() { Text = x.Key.Name, FontWeight = System.Windows.FontWeights.Bold, Margin = new System.Windows.Thickness(0, 3, 0, 0) });
}
//Asks for the new name and performs the renaming
var input = new InputBox("New name", content);
if (input.ShowDialog().GetValueOrDefault(false) && !string.IsNullOrEmpty(input.Value))
{
//Performs renaming
foreach (var x in rename)
x.Key.Name = string.Format(x.Value, input.Value);
//Refreshes the view
MainWindow.Instance.RefreshDecompiledView();
selectedNodes[0].Foreground = ILEdit.GlobalContainer.NewNodesBrush;
MainWindow.Instance.RefreshTreeViewFilter();
}
}
示例11: archiveMonthToolStripMenuItem_Click
private void archiveMonthToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var input = new InputBox("Enter a Month", "Please enter the month you are archiving"))
{
string inputtxt;
if (input.ShowDialog() == DialogResult.OK)
inputtxt = input.InputText.ToUpper();
else
return;
ReadArchives();
var exists = _archived.Where(item => String.Compare(item.MonthName.ToUpper(), inputtxt, StringComparison.Ordinal) == 0);
if (!exists.Any())
{
double projTotal = _projData.Sum();
double currTotal = _currData.Sum();
_archived.Add(new ArchiveMonth(input.InputText, _projData, projTotal, _listFinances, currTotal));
WriteArchives();
UIHelper.ClearList(lstItems);
_listFinances = new List<FinanceEntry>();
_currData = new List<double>();
InitProjectionData();
Utilities.LoadID(_listFinances);
WriteXML();
Recalculate();
MessageBox.Show("Your total spending for the month left you with: " + (projTotal - currTotal).ToString(Formats.MoneyFormat), "Monthly Total");
}
else
MessageBox.Show("Error: There is already an entry with the same name","Error");
_archived = null;
}
}
示例12: Run
public override void Run()
{
IWfBox owner = this.Owner as IWfBox;
if (owner != null)
{
InputBox box2 = new InputBox("请输入使用的远程DAO对象地址:", "提示", "http://127.0.0.1:7502/DBDAO");
if (box2.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
{
string result = box2.Result;
if (!string.IsNullOrEmpty(result))
{
WaitDialogHelper.Show();
try
{
(owner as WfBox).SaveAsProinsts(result);
}
catch (Exception exception)
{
MessageHelper.ShowInfo("发生错误:{0}", exception.Message);
LoggingService.Error(exception);
}
finally
{
WaitDialogHelper.Close();
}
}
}
}
}
示例13: Show
/// <summary>
/// Displays a prompt in a dialog box, waits for the user to input text or click a button.
/// </summary>
/// <param name="prompt">String expression displayed as the message in the dialog box</param>
/// <param name="title">String expression displayed in the title bar of the dialog box</param>
/// <param name="defaultResponse">String expression displayed in the text box as the default response</param>
/// <param name="validator">Delegate used to validate the text</param>
/// <param name="keyPressHandler">Delete used to handle keypress events of the textbox</param>
/// <param name="xpos">Numeric expression that specifies the distance of the left edge of the dialog box from the left edge of the screen.</param>
/// <param name="ypos">Numeric expression that specifies the distance of the upper edge of the dialog box from the top of the screen</param>
/// <returns>An InputBoxResult object with the Text and the OK property set to true when OK was clicked.</returns>
public static InputBoxResult Show(string prompt, string title, string defaultResponse, InputBoxValidatingHandler validator, KeyPressEventHandler keyPressHandler, int xpos, int ypos)
{
using (InputBox form = new InputBox())
{
form.label.Text = prompt;
form.Text = title;
form.textBox.Text = defaultResponse;
if (xpos >= 0 && ypos >= 0)
{
form.StartPosition = FormStartPosition.Manual;
form.Left = xpos;
form.Top = ypos;
}
form.Validator = validator;
form.KeyPressed = keyPressHandler;
DialogResult result = form.ShowDialog();
InputBoxResult retval = new InputBoxResult();
if (result == DialogResult.OK)
{
retval.Text = form.textBox.Text;
retval.OK = true;
}
return retval;
}
}
示例14: AddButton_Click
private void AddButton_Click(object sender, EventArgs e)
{
var input = new InputBox("请输入一个名字:", "新增操作者", "");
var result = input.ShowDialog(this);
if (result == DialogResult.OK)
{
var name = input.InputResult.Trim();
bool nameExists = false;
foreach (string n in OperatorsListBox.Items) {
if (n == name)
{
nameExists = true;
break;
}
}
if (!nameExists)
{
var db = new DataProcess();
db.addOperator(name);
OperatorsListBox.Items.Add(name);
}
else
{
MessageBox.Show(this, "名字已存在,请勿重复添加。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}
示例15: Run
public override void Run()
{
if (this.IsEnabled)
{
InputBox box = new InputBox("请输入使用的远程服务自动升级对象地址:", "提示:", "http://127.0.0.1:7502/RemoteUpdate");
string result = string.Empty;
if (box.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
{
result = box.Result;
if (string.IsNullOrEmpty(result))
{
MessageHelper.ShowInfo("没有输入远程对象地址");
}
else
{
try
{
(Activator.GetObject(typeof(IRemoteUpdate), result) as IRemoteUpdate).Execute();
MessageHelper.ShowInfo("远程服务执行升级操作成功!");
}
catch (Exception exception)
{
MessageHelper.ShowError("远程服务执行升级操作发生错误", exception);
LoggingService.Error(exception);
}
}
}
}
}