|
Yesterday i've received an interesting "feature"(or bug?).
My form has context menu (ContextMenuStrip) with two levels:
menuItem_1
-> menuItem_1_1
-> menuItem_1_2
menuItem_2
every menu item has Click event handler:
<br />
void MenuItem_Click(object sender, EventArgs e)<br />
{<br />
ToolStripMenuItem item = (ToolStripMenuItem)sender;<br />
ContextMenuStrip menu = item.Owner as ContextMenuStrip;<br />
MessageBox.Show(menu == null ? "false" : "true");<br />
}<br />
I've got:
menuItem_1 click => true
menuItem_1_1 click => false
menuItem_1_2 click => false
menuItem_2 click => true
So, ToolStripMenuItem's Owner on 2+ level is not a ContextMenuStrip!!! Is it normal? I bet - not...
And how I can receive the reference to the ContextMenuStrip to which the 2+ level menu item belongs?
|
|
|
|
|
First you should check (in the debugger or by calling GetType()) what type the item.Owner actually is. I have a feeling for the submenus it would probably be ToolStripDropDown, not ContextMenuStrip. If you're looking to get a ref to the parent ContextMenuStrip, you might have to do something like ToolStripDropDown.OwnerItem.Owner.
Logan
{o,o}.oO( Did somebody say “mouse”? )
|)””’)
-”-”-
|
|
|
|
|
Yes... item.Owner isn't ContextMenuStrip - it's type is ToolStripDropDownMenu.
Construction like item.OwnerItem.Owner is not comprehensible, because:
1) It works for 2 level menu only, not for 3+
2) For first level it throws exception
Certainly, it is possible to use construction like:
<br />
ToolStripItem parent = item;<br />
while(parent.OwnerItem != null)<br />
parent = parent.OwnerItem;<br />
ContextMenuStrip menu = (ContextMenuStrip)parent.Owner;<br />
... but it looks not as it would be desirable.
P.S. What for the reference to object which property item.Owner (on 2+ level) refers is necessary to me?
|
|
|
|
|
I used nant to build ASP .NET application my VS 2005 .sln file
is being compiled using nant builder ..I heard that nant is used to compile and deploy the ASP .NET application ......
Can anyone plese tell me how to deploy ASP .NET application using nant. I have compiled file ready i want to know how to deploy it...
I m using VS 2005 and Nant-0.85
aaa
|
|
|
|
|
Have you resolved this?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
sry, i know this is prob in the wrong place but hopefully someone can help with my question...
i want to know if there is a javascript code that can be executed in internet explorer to make the send message form load on a page, then link the page
|
|
|
|
|
|
You're right. This is the wrong forum. Plus, you have to be more patient. Waiting only 20 minutes for an answer before posting about it again is pretty bad form. Now - post this on the web forum, and post the message so that it actually makes sense. I didn't have a clue what you were trying to do.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
My question about ado disconnect mode
I wanna used SQL Statement (INSERT INTO,UPDATE,DELETE,SELECT) with ADO Disconnect Mode
Who can I do it?
Thanks
|
|
|
|
|
If you are using SQL Server, you can use the SqlDataAdapter[^] class. Set the InsertCommand and DeleteCommand properties and then call the Update method to update your database.
Paul Marfleet
|
|
|
|
|
Hi. I'm writing an RSS reader and have just discovered it doesn't work with international characters. I'm handling UTF-8 just fine and can handle extended "special" characters, like accents and so on, but for some reason I cannot draw Chinese characters.
Here's the low-down:
I set a breakpoint to check the internal value of a string, which, when I view it using the VS2005 string viewer, shows the proper Chinese characters. However when I draw this to the screen using DrawString (in font Tahoma 8.25f), I get boxes. I also get boxes if I pass the string to MessageBox.Show().
What do I need to do to draw these characters properly?? As I said they ARE there when I view the string inside VS... ??
Logan
{o,o}
|)””’)
-”-”-
|
|
|
|
|
In case you installed the Asian font support for this test and skipped rebooting because you could see the ofnts where already working (in VS for example), the it is time to reboot.
As far as I remmeber Tahoma should work just fine with Chinese, but you can always try some other fonts as the square is typically an indicator of a font problem (if you get a lot of question marks or strange character sequences then it is typically an encoding problem).
|
|
|
|
|
Is Asian font support an option while installing Windows? I don't remember if I installed that or not, but if I can see the characters properly in VS doesn't that imply that I do have that installed?
It seems the only font that works to display the characters is "SimSun", which is clearly a special Chinese font.
Are these characters not supported by standard fonts?? That's a shame if it is so because I did not account for that in my design and I don't want to leave my eastern friends out.
{o,o}
|)””’)
-”-”-
|
|
|
|
|
Yes, you can add them while installing - or anytime later.
Wikipedia[^]
Standard fonts should support Chinese etc once you have installed the Asian fonts.
|
|
|
|
|
Well I can see those fonts properly so it must be installed. However I still get only boxes when I use the regular Graphics.DrawString() with any font other than SimSun.
Perhaps it is a string encoding problem.
{o,o}
|)””’)
-”-”-
|
|
|
|
|
If it was an encoding problem SimSum should not work either.
Copy pasting the Chinese text from the wikipedia site into Notepad I have no problem displaying it with Tahoma - so the font should support it.
|
|
|
|
|
Ah, but I think Wordpad (I'm sure you mean Wordpad) is specially programmed to interpret Chinese characters on a character by character basis, dynamically changing the font (internally) to display it appropriately.
Because... if you copy and paste the text from Wiki into a label control on a WinForm (even just in designer mode), you get boxes.
I've managed a last-minute workaround by implementing a "Chinese character mode" in my program which simply changes all of the necessary fonts to SimSun. Until I find a proper solution (maybe WPF will be better when I migrate to it) this will at least enable east-Asian users to use my program.
{o,o}.oO(i need something funny to say--any ideas?)
|)””’)
-”-”-
|
|
|
|
|
I mean Notepad
Neither my Vista nor Windows 2003 systems have problem displaying the Chinese text in Notepad using the Tahoma font. If your system can't do it, then your font install is messed up.
|
|
|
|
|
Interesting, I only get blocks in Notepad. I will look into this and see what I can find out, although I plan to upgrade to Vista soon so I may just wait until I do (and be sure to install the appropriate international fonts when I do).
Thanks for the help.
{o,o}.oO( I need something funny to say--any ideas? )
|)””’)
-”-”-
|
|
|
|
|
Hi,
I have an xml file having hex values in the format 0x3fa and other values..and a xml schema for it having data type hexBinary for the corresponding hex values. When I create a dataset using the xml file and the schema, all the hex values are missing when displayed but the integer and string are fine.
Does anybody have any suggestion or idea for what I could be missing.
Thanks
Sumy
|
|
|
|
|
Hex is just a representation of a number. It's no different than an integer.
What does the code look like that's outputting the XML file?
|
|
|
|
|
Hi Dave,
Yes, i understand that hex is a representation of a number.
But when I loop through the tables and column values in the dataset to print them, the hex values are not getting printed. This is only when I represent it as hexBinary in the XML Schema. But if I represent the same hex value dataType in the schema as NMTOKEN, I can see it getting printed.
Actually I want to eventually load this to the MS SQL Server database. So I have the column datatype as binary for all these hex values.
Thanks
Sumy
|
|
|
|
|
Here is an idea (C# syntax):
int.TryParse("12", NumberStyles.HexNumber);
int.TryParse("0x12", NumberStyles.HexNumber);
int.TryParse("0x12", NumberStyles.HexNumber|NumberStyles.AllowHexSpecifier);
so what I am saying is:
1. check the "0x" prefix is present
2. maybe whatever reads the XML file uses the same code that fails to accept hex specifiers.
BTW: the hex specifiers are language-dependent (0x in C#, &H in VB.NET). Wouldn't that
make XML language-dependent?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc,
Thanks for your response. But my coding is almost dynamic, I am creating my database tables with the datatypes that I have in the schema and then I am loading all the values from the xml file to the database.
I am including a small part of my code where I am just printing the values by looping through the dataset and where the hex values are getting omitted.
foreach(DataTable table in dataset.Tables)
{
Console.WriteLine("TableName = " + table.TableName);
Console.WriteLine ("{0}", "---------");
Console.WriteLine("Columns ...");
foreach(DataColumn column in table.Columns)
{
Console.Write("{0,-22}",column.ColumnName);
}
Console.WriteLine("\r\nNumber of rows = {0}", table.Rows.Count.ToString());
Console.WriteLine("Rows ...");
foreach(DataRow row in table.Rows)
{
foreach(Object value in row.ItemArray)
{
Console.Write("{0,-22}",value.ToString());
}
Console.WriteLine();
}
Console.WriteLine();
}
|
|
|
|
|
I don't see anything refering to ints or hex. Don't know what to think of it.
If you want real help, I suggest you show the code that writes the file, then
a part of the XML file showing how the hex numbers look like, then the code that
reads/shows the file.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|