بسم الله الرحمن الرحيم
أريد سؤالكم كيف أستطيع إستدعاء DialogBox في C# حتى أقوم بإدخال بيانات بواسطته
مثلا في فيجوال بيسك :
name=InpuBox("Enter The data");أو في الجافا :
String name=JOptionPane.showInputDialog(null,"Enter the Data');
بسم الله الرحمن الرحيم
أريد سؤالكم كيف أستطيع إستدعاء DialogBox في C# حتى أقوم بإدخال بيانات بواسطته
مثلا في فيجوال بيسك :
name=InpuBox("Enter The data");أو في الجافا :
String name=JOptionPane.showInputDialog(null,"Enter the Data');
ممكن تنشائة
ودة مثال لانشائة
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TableFactory
{
public partial class InputBox : Form
{
public static string Input;
public static string Result;
public InputBox()
{
InitializeComponent();
}
public InputBox(string message, string caption)
{
InitializeComponent();
this.Message.Text = message;
this.Text = caption;
}
public InputBox(string message, string caption, string NodeText)
{
InitializeComponent();
this.Message.Text = message;
this.Text = caption;
this.txtInput.Text = NodeText;
}
public InputBox(int Width, int Height, string message, string caption)
{
InitializeComponent();
this.Height = Height;
this.Width = Width;
this.Message.Text = message;
this.Text = caption;
}
private void btnCancel_Click(object sender, EventArgs e)
{
Result = "No";
this.Close();
}
private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == '\r')
{
btnOK_Click(sender,e);
}
}
private void btnOK_Click(object sender, EventArgs e)
{
if (txtInput.Text != "")
{
Input = txtInput.Text;
Result = "Yes";
}
else
{
Result = "No";
}
this.Close();
}
private void InputBox_Load(object sender, EventArgs e)
{
txtInput.Focus();
}
}
}كل ما أنت تضعة على الform
label his name is Message,
TextBox===>txtInput
Two buttons===>btnOK and btnCancel
وعند إستخدامها لازم أعرف ان المستخدم دخل قيمة فى الtextbox ولا لأ علشان زلازم أعرف هل هوة أتك على ok or cancel
مثال لاستخدامها
InputBox box = new InputBox("Please Enter The New Name :", "TableFactory", treeView1.SelectedNode.Text);
box.ShowDialog();
if (InputBox.Result == "Yes")
{
treeView1.SelectedNode.Text = InputBox.Input;اليك مثال يوضح ال DialogBox
أشكركم جميعا أخواني على هذه المساعدات القيمة والرائعة منكم
تحياتي
هذا الموضوع مغلق.