473,321 Members | 1,877 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,321 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 3402
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.