当前位置: 首页>>代码示例>>C#>>正文


C# InputBox.Dispose方法代码示例

本文整理汇总了C#中InputBox.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# InputBox.Dispose方法的具体用法?C# InputBox.Dispose怎么用?C# InputBox.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InputBox的用法示例。


在下文中一共展示了InputBox.Dispose方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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;
        }
开发者ID:fabriceleal,项目名称:ImageProcessing,代码行数:26,代码来源:InputBox.cs

示例2: ShowDialog

        public static InputBoxResult ShowDialog(IWin32Window owner, string captionText, string defaultValue, Image iconImage)
        {
            InputBox inputBox = new InputBox();

            inputBox.Caption = captionText;
            inputBox.InputValue = defaultValue;
            inputBox.IconImage = iconImage;

            InputBoxResult result = new InputBoxResult();

            result.dialogResult = inputBox.ShowDialog(owner);

            result.val = inputBox.InputValue;

            inputBox.Dispose();
            inputBox = null;

            return result;
        }
开发者ID:hostitherepc,项目名称:Fork-1,代码行数:19,代码来源:InputBox.cs

示例3: Show

		public static string Show(string title, string label, string textbox)
		{
			InputBox box = new InputBox();
			box.Text = title;
			box.label.Text = label;
			box.textbox.Text = textbox;

			box.ShowDialog();
			string retval = box.retval;
			box.Dispose();
			return retval;
		}
开发者ID:HosokawaKenchi,项目名称:powersdr-if-stage,代码行数:12,代码来源:InputBox.cs

示例4: Show

    public static String Show(String Prompt, String Title = "", String DefaultResponse = "", int XPos = -1, int YPos = -1)
    {
        InputBox form = new InputBox();

        Form parent = null;
        if (Application.OpenForms.Count > 0)
            parent = Application.OpenForms[0];

        if (Prompt != null)
            form.lblPrompt.Text = Prompt;

        if (Title != null && Title.Length > 0)
        {
            form.Text = Title;
        }
        else if (parent != null)
        {
            form.Text = parent.Text;
        }

        if (DefaultResponse != null && DefaultResponse.Length > 0)
            form.txtOutput.Text = DefaultResponse;

        if (XPos >= 0 && YPos >= 0)
        {
            form.StartPosition = FormStartPosition.Manual;
            form.DesktopLocation = new Point(XPos, YPos);
        }
        else if (parent != null)
            form.StartPosition = FormStartPosition.CenterParent;
        else
            form.StartPosition = FormStartPosition.CenterScreen;

        form.ShowDialog(parent);

        String ret = form.Output;
        form.Dispose();
        return ret;
    }
开发者ID:mblaine,项目名称:public,代码行数:39,代码来源:InputBox.cs

示例5: ShowDialog


//.........这里部分代码省略.........
				inputBox.Text = caption;
			}

			if (!string.IsNullOrEmpty(prompt))
			{
				inputBox.lblPrompt.Text = prompt;
			}

			if (!string.IsNullOrEmpty(defaultValue))
			{
				inputBox.defaultValue = inputBox.txtInput.Text = defaultValue;
			}

			// Calculate size required for prompt message and adjust
			// Label and dialog size to fit.
			Size promptSize = inputBox.lblPrompt.CreateGraphics().MeasureString(prompt, inputBox.lblPrompt.Font,
			   inputBox.ClientRectangle.Width - 20).ToSize();
			// a little wriggle room
			if (promptSize.Height > inputBox.lblPrompt.Height)
			{
				promptSize.Width += 4;
				promptSize.Height += 4;
			}
			inputBox.lblPrompt.Width = inputBox.ClientRectangle.Width - 20;
			inputBox.lblPrompt.Height = Math.Max(inputBox.lblPrompt.Height, promptSize.Height);

			int postLabelMargin = 2;
			if ((inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin) > inputBox.txtInput.Top)
			{
				inputBox.ClientSize = new Size(inputBox.ClientSize.Width, inputBox.ClientSize.Height +
				   (inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin - inputBox.txtInput.Top));
			}
			else if ((inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin) < inputBox.txtInput.Top)
			{
				inputBox.ClientSize = new Size(inputBox.ClientSize.Width, inputBox.ClientSize.Height -
				   (inputBox.lblPrompt.Top + inputBox.lblPrompt.Height + postLabelMargin - inputBox.txtInput.Top));
			}

			// Ensure that the value of input is set
			// There will be a compile error later if not
			input = string.Empty;

			// Declare a variable to hold the result to be
			// returned on exitting the method
			DialogResult result = DialogResult.None;

			// Loop round until the user enters
			// some valid data, or cancels.
			while (result == DialogResult.None)
			{
				result = inputBox.ShowDialog();

				if (result == DialogResult.OK)
				{
					// if user clicked OK, validate the entry
					input = inputBox.txtInput.Text;

					// Only test if specific type is required
					if (validationType != InputBoxResultType.Any)
					{
						// If the test fails - Invalid input.
						if (!inputBox.Validate(validationType))
						{
							// Set variables ready for another loop
							input = string.Empty;
							// result to 'None' to ensure while loop
							// repeats
							result = DialogResult.None;
							// Let user know there is a problem
							MessageBox.Show(inputBox, "La informacion que ha ingresado no es valida " + validationType.ToString() + ".");
							// Set the focus back to the TextBox
							inputBox.txtInput.Select();
						}
					}
				}
				else
				{
					// User has cancelled.
					// Use the defaultValue if there is one, or else
					// an empty string.
					if (string.IsNullOrEmpty(inputBox.defaultValue))
					{
						input = string.Empty;
					}
					else
					{
						input = inputBox.defaultValue;
					}
				}
			}

			// Trash the dialog if it is hanging around.
			if (inputBox != null)
			{
				inputBox.Dispose();
			}

			// Send back the result.
			return result;
		}
开发者ID:Avaruz,项目名称:Avaruz.FrameWork,代码行数:101,代码来源:InputBox.cs


注:本文中的InputBox.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。