Windows Develop Bookmark and Share   
 index > Windows Forms General > how to embed a label in a toolstriptextbox
 

how to embed a label in a toolstriptextbox

I know this can be done in a textbox as found here http://www.codeproject.com/KB/cs/Parasite_Pattern2.aspx

But how do you do it in a toolstriptextbox?

Thanks,

Adam Howard

putnum1  Saturday, April 05, 2008 12:02 AM

You can do it in essentially the same way.

The trick is to get at the events--not of the ToolStripTextBox--but of the ToolStripTextBox.TextBox

You can do this programmatically

AddHandler ToolStripTextBox.TextBox.[EventName], AddressOf [NameOfYourEventHandlerSub]

Here's how you can show the list of available events from those pull-down menus at the top of the code window:

In your class, declare something like

Private WithEvents MenuTextBox as TextBox = Me.ToolStripTextBox1.Textbox

Now if you pull down the box on the left, you'll see MenuTextBox. Note that it is just a regular TextBox.

Select that, and on the right you'll see all of the events for the TextBox inside the ToolStripTextBox.

From there, you can do exactly the same thing as in that page to which you linked.

JayStation3  Saturday, April 05, 2008 12:25 AM

You can do it in essentially the same way.

The trick is to get at the events--not of the ToolStripTextBox--but of the ToolStripTextBox.TextBox

You can do this programmatically

AddHandler ToolStripTextBox.TextBox.[EventName], AddressOf [NameOfYourEventHandlerSub]

Here's how you can show the list of available events from those pull-down menus at the top of the code window:

In your class, declare something like

Private WithEvents MenuTextBox as TextBox = Me.ToolStripTextBox1.Textbox

Now if you pull down the box on the left, you'll see MenuTextBox. Note that it is just a regular TextBox.

Select that, and on the right you'll see all of the events for the TextBox inside the ToolStripTextBox.

From there, you can do exactly the same thing as in that page to which you linked.

JayStation3  Saturday, April 05, 2008 12:25 AM

whenever i do this

Private WithEvents MenuTextBox as TextBox = Me.ToolStripTextBox1.Textbox

I get errors. withevents doesn't seem to popup. any ideas?

putnum1  Saturday, April 05, 2008 1:03 AM
putnum1 wrote:

whenever i do this

Private WithEvents MenuTextBox as TextBox = Me.ToolStripTextBox1.Textbox

I get errors. withevents doesn't seem to popup. any ideas?

using c# if that helps. Smile

putnum1  Saturday, April 05, 2008 1:11 AM

Yes, that helps -- I wrote VB.

Here's my attempt at C#, which does not require the WithEvents:

Code Snippet

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

private TextBox MenuTextbox = this.toolstriptextbox1.textbox;

public Form1()

{

InitializeComponent();

MenuTextbox.TextChanged += new EventHandler(MenuTextbox_TextChanged);

//add any other event handlers in the same way

//if you create the delegates delegates or whatever the

//handlers functions are called in C# like the one below

//first, then when you go to add the event handlers

//intellisense will give you a list of the available ones

//and you can just select it and press tab to enter the

//correct syntax

}

public void MenuTextBox_TextChanged(object sender, EventArgs e)

{

//event stuff here

}

}

}

JayStation3  Saturday, April 05, 2008 5:56 AM

You can use google to search for other answers

Custom Search

More Threads

• Destructor is not called
• Mouseover anywhere on a user control
• Custom Rich Text Editor Control (Similar Functionality of Outlook To, Cc, Bcc Field)
• FORM CLOSE ISSUE
• I have i custom openfile dialog how can i embed it to my form
• Bitmap Resizing - Out of Memory Error
• ASP.NET Web Application on Linux Server
• BackgroundWorker ReportProgress Multi-Core
• How to make the windows form invisible for first time
• how to tell when the computer is being shutdown or user is logging off?