我有下面的代碼,允許用戶在可執行文件(即notepad.exe)中寫入,然後單擊開始按鈕它將啓動該過程。接受文本框輸入/返回
但是,如何使文本框接受輸入/返回鍵?我把AcceptsReturn=true
,但它沒有做任何事情。我也在Visual Studio中設置了屬性Accept Return = True
- 仍然沒有。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
namespace process_list
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string text = textBox1.Text;
Process process = new Process();
process.StartInfo.FileName = text;
process.Start();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.AcceptsReturn = true;
}
}
}
輝煌 - 非常感謝! – lara400