473,386 Members | 1,820 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,386 software developers and data experts.

Converting from VS2003 to VS2005

I am trying to convert code that worked in a Visual Studio 2003 project to
code that will work in a Vsual Studio 2005 project
and need help.

The following is the VS2003 code:
private void mnuColorItem_Click(

object sender, System.EventArgs e)

{

MenuItem mnuItem = (MenuItem)sender;

//Get the color name from the menu item text

//while removing the & character in that text

rbText.SelectionColor = Color.FromName(

mnuItem.Text.Replace("&", ""));

//Uncheck all menu items inside the color menu

foreach (MenuItem m in mnuItem.Parent.MenuItems)

m.Checked = false;

mnuItem.Checked = true;

}
In VS 2005 this doesn't work because the menu is now a ToolStrip and
MenuItem is now a ToolStripMenuItem...
But when I change that then I can't access the parent because it is
protected. I am not sure what I have to change to get at that data....
That is what I need help with right now.
Sep 20 '06 #1
3 3025
Henry,

You can use in version 2005 the same menus as in version 2003, there is no
need for the language to use toolstrips, which are of course other classes
with their own methods.

Cor

"Henry" <he*********@myquest-tech.comschreef in bericht
news:uB**************@TK2MSFTNGP03.phx.gbl...
>I am trying to convert code that worked in a Visual Studio 2003 project to
code that will work in a Vsual Studio 2005 project
and need help.

The following is the VS2003 code:
private void mnuColorItem_Click(

object sender, System.EventArgs e)

{

MenuItem mnuItem = (MenuItem)sender;

//Get the color name from the menu item text

//while removing the & character in that text

rbText.SelectionColor = Color.FromName(

mnuItem.Text.Replace("&", ""));

//Uncheck all menu items inside the color menu

foreach (MenuItem m in mnuItem.Parent.MenuItems)

m.Checked = false;

mnuItem.Checked = true;

}
In VS 2005 this doesn't work because the menu is now a ToolStrip and
MenuItem is now a ToolStripMenuItem...
But when I change that then I can't access the parent because it is
protected. I am not sure what I have to change to get at that data....
That is what I need help with right now.

Sep 20 '06 #2
I might be able to do that, but it would mean rebuilding the entire menu
system.
I am hoping that the solution is simpler than that.

It appears to be an access issue. Here is the error message:

'System.Windows.Forms.ToolStripItem.Parent' is inaccessible due to its
protection level E:\Projects\70-316\Chapter2\StepByStep2_18.cs 74 44
Chapter2

I have tried to address this by changing the access modifier for the parent
control(s) of the specific menu items to public from private. I am still
getting the error message though.
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eg**************@TK2MSFTNGP05.phx.gbl...
Henry,

You can use in version 2005 the same menus as in version 2003, there is no
need for the language to use toolstrips, which are of course other classes
with their own methods.

Cor

"Henry" <he*********@myquest-tech.comschreef in bericht
news:uB**************@TK2MSFTNGP03.phx.gbl...
>>I am trying to convert code that worked in a Visual Studio 2003 project to
code that will work in a Vsual Studio 2005 project
and need help.

The following is the VS2003 code:
private void mnuColorItem_Click(

object sender, System.EventArgs e)

{

MenuItem mnuItem = (MenuItem)sender;

//Get the color name from the menu item text

//while removing the & character in that text

rbText.SelectionColor = Color.FromName(

mnuItem.Text.Replace("&", ""));

//Uncheck all menu items inside the color menu

foreach (MenuItem m in mnuItem.Parent.MenuItems)

m.Checked = false;

mnuItem.Checked = true;

}
In VS 2005 this doesn't work because the menu is now a ToolStrip and
MenuItem is now a ToolStripMenuItem...
But when I change that then I can't access the parent because it is
protected. I am not sure what I have to change to get at that data....
That is what I need help with right now.


Sep 20 '06 #3
I found the answer! See the code below:

It appears that the parent object is revealed by a method rather than a
property.

So the code I needed after changing to ToolStripMenuItem types was

"mnuItem.GetCurrentParent().Items"
private void mnuColorItem_Click(

object sender, System.EventArgs e)

{

ToolStripMenuItem mnuItem = (ToolStripMenuItem)sender;

//Get the color name from the menu item text

//while removing the & character in that text

rbText.SelectionColor = Color.FromName(

mnuItem.Text.Replace("&", ""));

//Uncheck all menu items inside the color menu

foreach (ToolStripMenuItem m in

mnuItem.GetCurrentParent().Items)

m.Checked = false;

mnuItem.Checked = true;

}

"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eg**************@TK2MSFTNGP05.phx.gbl...
Henry,

You can use in version 2005 the same menus as in version 2003, there is no
need for the language to use toolstrips, which are of course other classes
with their own methods.

Cor

"Henry" <he*********@myquest-tech.comschreef in bericht
news:uB**************@TK2MSFTNGP03.phx.gbl...
>>I am trying to convert code that worked in a Visual Studio 2003 project to
code that will work in a Vsual Studio 2005 project
and need help.

The following is the VS2003 code:
private void mnuColorItem_Click(

object sender, System.EventArgs e)

{

MenuItem mnuItem = (MenuItem)sender;

//Get the color name from the menu item text

//while removing the & character in that text

rbText.SelectionColor = Color.FromName(

mnuItem.Text.Replace("&", ""));

//Uncheck all menu items inside the color menu

foreach (MenuItem m in mnuItem.Parent.MenuItems)

m.Checked = false;

mnuItem.Checked = true;

}
In VS 2005 this doesn't work because the menu is now a ToolStrip and
MenuItem is now a ToolStripMenuItem...
But when I change that then I can't access the parent because it is
protected. I am not sure what I have to change to get at that data....
That is what I need help with right now.


Sep 21 '06 #4

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

Similar topics

0
by: John | last post by:
Hi all, I have a couple of web sites I want to convert from VS2003 to VS2005 for testing and messing around with. The problem I have is that in VS2005 when I take the 'open web site' option,...
3
by: Darrin | last post by:
Hello, I see that VS2005 and the new framework 2.0 is out to the public now. Wondering about some things. When you install the new framework 2.0 can a person still use visual studio 2003 or...
9
by: Michael Tissington | last post by:
After converting from 6.0 to 2005 when I try to Compile my project I'm getting a LINK error Error 1 fatal error LNK1181: cannot open input file " ?/.obj" Any ideas how to fx this please ? ...
15
by: Joseph Geretz | last post by:
OK, I'll admit it up front - I just don't get it. Here's our previous VS2003 development model. Developers develop the WS solution on their own workstations, using their own IIS web servers...
2
by: Tammam | last post by:
Hello, I converted a web solution from VS2003 to VS2005. The conversion process proceeded successfully with no errors and the new VS2005 solution builds with no error. When trying to run it, the...
5
by: Tony | last post by:
Hi all, Here's the link to the issue we were seeing on our ASP.NET system when modifying, adding and deleting directories in framework 2.0....
3
by: Marcus | last post by:
Hi, I converted my .Net1.1 application (written in VS2003) to a .Net2.0 application. I let VS2005 do the job as it suggested when trying to load my VS2003 project in VS2005. I then included the...
1
by: sureshhalade | last post by:
I want to migrate VS2003 Windows/Class library/console project to VS2005 Windows/Class library/console project. And the DLL out of VS2005 project should work as previously. Note: My main project...
0
by: Academia | last post by:
I have a vs2003 solution that I want to convert to VS2005 format. These projects have been converted and now compile in VS2005. But they had the older format - they is the UI code was in .vb...
1
by: kphip123 | last post by:
Hi! I recently converted an application from VS2003 to VS2005. The application consists of a main 'unmanaged C++ executable' which calls a managed C++ .dll. The .dll basically launches a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.