0 امتیاز

باسلام

چگونه می توان با نوشتن کد کاربر در textBox1 وزدن کلید Enter سایر اطلاعات کاربر در بقیه ی textBox ها قرار بگیرن مثل تصویر زیر

در مطالب آموزشی هم گشتم ولی نتونستم چیزی در این رابطه به دست بیارم

بسته شده

2 پاسخ

+1 امتیاز
 
بهترین پاسخ

برای استفاده از Enter  از کد زیر استفاده کنید :

static void tb_KeyDown(object sender, KeyEventArgs e)
{
    if (e.KeyCode == Keys.Enter)
    {
        //enter key is down
    }
}

 

0 امتیاز

سلام، یه همچین چیزی میشه

using System;
using System.Windows.Forms;

namespace DGV
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.dataGridView1.Rows.Add(1, "سیاوش", "ابراهیمی");
            this.dataGridView1.Rows.Add(2, "سروش", "ابراهیمی");
            this.dataGridView1.Rows.Add(3, "سارا", "امرایی");
            this.dataGridView1.Rows.Add(4, "محسن", "نظری");
            this.dataGridView1.Rows.Add(5, "ادیب", "سوری");
        }

        private void txtID_TextChanged(object sender, EventArgs e)
        {
            bool isFound = false;
            for (int i = 0; i < this.dataGridView1.RowCount; i++)
            {
                string id = this.dataGridView1.Rows[i].Cells["Id"].Value.ToString();
                if (id == this.txtID.Text)
                {
                    this.txtFirstName.Text = this.dataGridView1.Rows[i].Cells["FirstName"].Value.ToString();
                    this.txtLastName.Text  = this.dataGridView1.Rows[i].Cells["LastName"].Value.ToString();
                    isFound = true;
                    break;
                }
            }

            if (!isFound)
            {
                this.txtFirstName.Text = string.Empty;
                this.txtLastName.Text = string.Empty;
            }
        }
    }
}

 

چگونه می توان دستور enter را اضافه کرد؟
توسط (120 امتیاز) 1 8
سوال جدید

2,335 سوال

2,871 پاسخ

3,725 دیدگاه

3,916 کاربر

دسته بندی ها

...