الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

كيف أنشأ DialogBox

مغلق
بدأه MKSoft في 7 سبتمبر 2005 · 6 رد · 591 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

بسم الله الرحمن الرحيم

أريد سؤالكم كيف أستطيع إستدعاء DialogBox في C# حتى أقوم بإدخال بيانات بواسطته

مثلا في فيجوال بيسك :

name=InpuBox("Enter The data");

أو في الجافا :

String name=JOptionPane.showInputDialog(null,"Enter the Data');
#3

ممكن تنشائة

ودة مثال لانشائة

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;

Muhammad Allam

Computer Science

@Resource(MappedURL="My Blog" )

#4

اليك مثال يوضح ال DialogBox

WindowsApplication14.zip

#5

تنبيه بسيط فقط

الكود في المشاركة 3 هو كود C# 2.0 أي أنه لن يعمل على Visual Studio 2003

Sr. Software Development Engineer
Hulu, LLC
My Blogs

#6

أشكركم جميعا أخواني على هذه المساعدات القيمة والرائعة منكم

تحياتي

#7

ياسلام على يابشمهندس محمد

أأسف أنا نسيت أعرفكم ان الكود دة مكتوب على vs beta2 يعنى مش هيشتغل على vs2003

Muhammad Allam

Computer Science

@Resource(MappedURL="My Blog" )

هذا الموضوع مغلق.

مواضيع مشابهة