WinForms テキストボックスには、ボックスの最後に埋め込みボタンを可能にするプロパティがありますか?
Chrome アドレス ボックスのお気に入りボタンのようなもの:
また、いくつかの Excel フォームで次のようなものを見てきました。
編集
Hans Passant の回答に従って、クリック イベント ハンドラーを追加しましたが、問題なく動作しているようです。
protected override void OnLoad(EventArgs e) {
var btn = new Button();
btn.Size = new Size(25, textBoxFolder.ClientSize.Height + 2);
btn.Location = new Point(textBoxFolder.ClientSize.Width - btn.Width, -1);
btn.Cursor = Cursors.Default;
btn.Image = Properties.Resources.arrow_diagright;
btn.Click += btn_Click;
textBoxFolder.Controls.Add(btn);
// Send EM_SETMARGINS to prevent text from disappearing underneath the button
SendMessage(textBoxFolder.Handle, 0xd3, (IntPtr)2, (IntPtr)(btn.Width << 16));
base.OnLoad(e);
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
private void btn_Click(object sender, EventArgs e) {
MessageBox.Show("hello world");
}