50٪ تخفیف روی تمام دوره‌ها!
پایان تخفیف تا:
مشاهده دوره‌ها
0

نحوه و چگونگی اجرایی مثال هایی ماکروسافت در ویژوال استادیو

با سلام

میخواستم بدون نحوه اجرایی مثال هایی ماکرو سافت در VS چگونه است من زمانی که اونها رو کپی میکنم تو VS ارور میدهد ..

میخواستم دوستان اگر می دونند راهنمایی کنند راهنمایی کنند ..

مثلا من این صفحه رو میخواستم اجرا کنم اما ...

پرسیده شده در 1394/07/23 توسط

5 پاسخ

0

توی تابع constructor فرم یعنی تابع زیر توی کد بالا تابع ... را فراخوانی کن:

public Form1()
        {
 
            InitializeComponent();
            InitializeRadioButtons();
        }

ولطفا اگه زحمتی نیست به جای واژه «تنکس» پسندیدم و یا انتخاب به عنوان جواب رو روی پست بنده کلیک کنیدD:

پاسخ در 1394/07/24 توسط
1

خودش بالای مثال توضیح داده برای اجرا چی کار کنید:

To run this example, paste the code into a Windows Form. Call InitializeRadioButtons from the form's constructor or the Load event-handling method.

ترجمه:

برای اجرای این مثال کد را درون یک window form کپی کنید و سپس درون تابع سازنده ان فرم تابع InitializeRadioButtons را فراخوانی کنید و یا اینکه در متد load صفحه فرم ان را فراخوانی نمائید.

پاسخ در 1394/07/23 توسط
1

تنکس .. اینطوری اضافه کردم اشکالی نگرفت البته region خودم اضافه کردم

برای دوستان دیگم گذاشتم استفاده کنن.

namespace ex_01
{
    public partial class Form1 : Form
    {
        #region - radio Button -
        private GroupBox groupBox1;
        private RadioButton radioButton2;
        private RadioButton radioButton1;
        private RadioButton selectedrb;
        private Button getSelectedRB;

        public void InitializeRadioButtons()
        {
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.radioButton2 = new System.Windows.Forms.RadioButton();
            this.radioButton1 = new System.Windows.Forms.RadioButton();
            this.getSelectedRB = new System.Windows.Forms.Button();

            this.groupBox1.Controls.Add(this.radioButton2);
            this.groupBox1.Controls.Add(this.radioButton1);
            this.groupBox1.Controls.Add(this.getSelectedRB);
            this.groupBox1.Location = new System.Drawing.Point(30, 100);
            this.groupBox1.Size = new System.Drawing.Size(220, 125);
            this.groupBox1.Text = "Radio Buttons";

            this.radioButton2.Location = new System.Drawing.Point(31, 53);
            this.radioButton2.Size = new System.Drawing.Size(67, 17);
            this.radioButton2.Text = "Choice 2";
            this.radioButton2.CheckedChanged += new EventHandler(radioButton_CheckedChanged);

            this.radioButton1.Location = new System.Drawing.Point(31, 20);
            this.radioButton1.Name = "radioButton1";
            this.radioButton1.Size = new System.Drawing.Size(67, 17);
            this.radioButton1.Text = "Choice 1";
            this.radioButton1.CheckedChanged += new EventHandler(radioButton_CheckedChanged);

            this.getSelectedRB.Location = new System.Drawing.Point(10, 75);
            this.getSelectedRB.Size = new System.Drawing.Size(200, 25);
            this.getSelectedRB.Text = "Get selected RadioButton";
            this.getSelectedRB.Click += new EventHandler(getSelectedRB_Click);

            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.groupBox1);
        }

        void radioButton_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton rb = sender as RadioButton;

            if (rb == null)
            {
                MessageBox.Show("Sender is not a RadioButton");
                return;
            }

            // Ensure that the RadioButton.Checked property
            // changed to true.
            if (rb.Checked)
            {
                // Keep track of the selected RadioButton by saving a reference
                // to it.
                selectedrb = rb;
            }
        }

        // Show the text of the selected RadioButton.
        void getSelectedRB_Click(object sender, EventArgs e)
        {
            MessageBox.Show(selectedrb.Text);
        }
        #endregion

        public Form1()
        {

            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            InitializeRadioButtons();
        }
        


    }
}

پاسخ در 1394/07/24 توسط
0

من با استفاده از call method اجرا کردم شد .. اما با روش با constructor نتونستم دوستان کسی میدونه توضیح بده ..

یا یه نمونه قرار بده ..

ممنون

پاسخ در 1394/07/24 توسط
0

جناب prober بنده تشکر میکنم ازتون ضمنا اگر استفاده نکردم از کلید پسنیدم حتما احساس میکردم که جواب شما کافی و کامل نیست و من نتونستم به جوابی که مند نظرم است برسم .. بازم هم ممنون و میچکرم از اطلاعاتی که در اختیار قرار دادید..

پاسخ در 1394/07/25 توسط

پاسخ شما