Click here to Skip to main content
16,020,974 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi,

Please help me.

How do I add a new Button into the TextBox Control?
If you click the button the system will show a new Filter Windows?

If you know how to achieve the requirement, please let me know.

Thanks
Posted
Updated 19-Apr-11 21:57pm
v3
Comments
Sergey Alexandrovich Kryukov 19-Apr-11 22:57pm    
Makes no sense. Reformulate it.
--SA
zyzhangdlx 19-Apr-11 23:14pm    
I have a idear, i add a new class whick inherited from textBox,but i don't know how to add this button into the write zoon
shakil0304003 19-Apr-11 23:20pm    
Your requirement is unclear.
zyzhangdlx 19-Apr-11 23:26pm    
me requirement is like this: i want to add a new button into the TextBox Control,the new control will also have all the TextBox's functions and also it have a extend function if user click the button will show a new window which will show some data and user can do some operation in this window. whether my requirement is clear now?
Sandeep Mewara 20-Apr-11 0:56am    
Button into textbox?

You can add existing button in textbox like this.
Button Button1 = new Button();
Button1.Dock = Forms.DockStyle.Right;
TextBox1.Controls.Add(Button1);

You have to bind button's event as required.
Button1.Click += new EventHandler(this.Button1_Click);


One problem: Some text may hide behind button with this approach. Better you place both side by side.
 
Share this answer
 
v2
Comments
zyzhangdlx 20-Apr-11 3:26am    
Tks,i used method is same as you ,i have overrided the method which name is "InitLayout" Like this:
protected override void InitLayout()
{
base.InitLayout();
this.Controls.Clear();
_Button.Size = new Size(30, this.Height);
_Button.Cursor = Cursors.Hand;
_Button.Dock = DockStyle.Right;
if (FilterIcon != null)
{
_Button.BackgroundImage = FilterIcon;
}
this.Controls.Add(_Button);
}


but i haven't found the solution to solve this problem
Prerak Patel 20-Apr-11 3:31am    
Then you just have to bind button's click event.
Button1.Click += new EventHandler(this.Button1_Click);
Dalek Dave 20-Apr-11 3:58am    
Good Answer.
A speculative way...you can put a TextBox and Button into a UserControl, change the size and location of it then write some thing like "public event EventHandler"...
 
Share this answer
 
v2
Comments
zyzhangdlx 21-Apr-11 2:00am    
this is a method,but i need to add more events.i have no more time

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900