473,246 Members | 1,845 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,246 software developers and data experts.

Toolbar and Windows Forms

Hi,

I have a little trouble trying to assign a Toolbar control to another
toolbar variable control.

I am getting my forms controls with this:

for (int j = 0; j <= frmChild.Controls.Count - 1; j++)
{
// Some operations

if (ctrl.GetType().ToString() ==
"System.Windows.Forms.ToolBar")
{
MessageBox.Show("paso");
System.Windows.Forms.ToolBar toolBarX = ctrl;
}
}

I just want to access to the "buttons" property of my toolbar control,
in order to enabled or disabled toolbar buttons getting their tag
names.

Is it possible?

Thanks,

Alfredo Barrientos

Dec 12 '05 #1
1 3399
I’m guessing that you are getting a compile error, something to the effect of:

Cannot implicitly convert type 'System.Windows.Forms.Control' to
'System.Windows.Forms.ToolBar'?

To fix that, you need to cast the reference you’ve got to your toolbar to an
actual toolbar... to do so, we’d change your line from:
System.Windows.Forms.ToolBar toolBarX = ctrl;

to

System.Windows.Forms.ToolBar toolBarX = (System.Windows.Forms.ToolBar)ctrl;

Note: You can drop the ‘System.Windows.Forms’ part if you’ve already got
that namespace being used.

Also, a couple of other quick thoughts... rather than compare each control
based on the types name... you could simply interrogate the object to
determine if it is the desired type ala:

if (ctrl is System.Windows.Forms.ToolBar)

Brendan
"Alfredo Barrientos" wrote:
Hi,

I have a little trouble trying to assign a Toolbar control to another
toolbar variable control.

I am getting my forms controls with this:

for (int j = 0; j <= frmChild.Controls.Count - 1; j++)
{
// Some operations

if (ctrl.GetType().ToString() ==
"System.Windows.Forms.ToolBar")
{
MessageBox.Show("paso");
System.Windows.Forms.ToolBar toolBarX = ctrl;
}
}

I just want to access to the "buttons" property of my toolbar control,
in order to enabled or disabled toolbar buttons getting their tag
names.

Is it possible?

Thanks,

Alfredo Barrientos

Dec 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jason Tabert | last post by:
Is there a way to create a custom IE toolbar with C# (or anything else in ..NET for that matter)? I have been looking all day and have had no luck finding a good place to start. I need to make...
5
by: anthony.duerr | last post by:
I have encountered a problem (most certainly a .NET bug), that, for the life of me, I cannot figure out how to work around. Using Visual Studio 2003, with enabled XP Visual Styles. There are...
2
by: Greg Burns | last post by:
I added a toolbar to a form and added one button. I made sure ShowToolTips = true for the Toolbar, and have set a tooltip for the button. The problem is the tooltip only shows after clicking...
9
by: Hugh | last post by:
after I changed the image size. I tried different combinations of images sizes and button sizes. I have tried both botton and the image in the same sizes or button size was larger than that of...
1
by: Curtis | last post by:
Somehow I'm just missing something. I don't know how to catch when a user clicks on an item in a dropdown list for a dropdown style button on a toolbar. I create a new app. Form1. Add a...
4
by: Fredrik Melin | last post by:
Have anyone seen a component or know how to create a button like toolbar dropdown button without the toolbar (to be used like a normal button) Regards Fredrik Melin
0
by: Syed Zaidi via .NET 247 | last post by:
I am working on a small project in which i want to develop acustom toolbar skeleton for handling database navigation. I havecreated a usercontrol consist of a toolbar inherits fromusercontrol and...
3
by: Flashster | last post by:
How do I create a moveable toolbar that can be docked on a windows form?. I'm using vb .net (2002). I have added the toolbar item to the windows form, but I cannot see a way of making it...
4
by: OldBirdman | last post by:
I'm working within the Access window because my program isn't quite completed. Some of my forms almost fill this space, which is as large as my monitor will support. If the Office Clipboard tries...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.