|
You might want to be careful changing the Name property of the controls (even MenuItems) at runtime. This property is what the runtime uses to identify each control, not what is displayed on screen. For that, you generally need to change the Text property.
There is a Name property for all UI controls, you may need to cast the object back to a MenuItem in order to access it.
|
|
|
|
|
Thanks. I know that I shouldnt change the Name property (if I remember correctly thats not possible). I do only need it to create a unique identification string to search that in my text files.
I've tried casting MenuItem back into Control but that gives me a compiler error :/
|
|
|
|
|
You shouldn't be casting MenuItem to Control , it should probably be the other direction. The Name property should always be unique (and if you're using the Forms designer it will guarantee that it is) so that should be your key into the text file.
Since you are trying to do localization, is there a reason you aren't using the built-in localization that Windows Forms and .NET provides?
|
|
|
|
|
I'm doing the localization just for educational purposes (or whatever you call that )
Just to know if I can do it.
I think the casting wont work since MenuItem is not derived from the Class (They are both derived from the Form Class if i remember correctly).
After trying for some time now I might stick with the solution to simply get the names of the menu itself and name the MenuItems Form1.mainMenu.Item1 to ...ItemXX. Cant get anything else to work :/
|
|
|
|
|
Hy
I have a RichTextBox.
When I press any alphabetic key on RichTextBox_KeyDown the e.KeyValue have the ascci code for the bigger letter. I press "q" and the e.KeyValue have the ascci code for "Q". How can I detect what key I pressed?
thanks
|
|
|
|
|
You've already identified what key you've pressed. Do you mean how do you work out what character it was? If so, just cast it to a string.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I cast to string.
When I press "q" the e.KeyValue = 81 ... the ascci code for "Q".
So I can detect If i press down "q" or "Q".
|
|
|
|
|
|
e.KeyCode and e.KeyValue have the same ascci value
|
|
|
|
|
You have only one key on the keyboard so that's why you are getting the same value. You can check for caps lock like this: Control.IsKeyLocked(Keys.CapsLock) and extract information about shift button from e.Keydata. Based on these two pieces of information you will be able to determine whether 'q' was typed or 'Q'
|
|
|
|
|
Hi,
KeyDown/KeyUp events offer a KeyEventArgs with amongst others these key information properties:
· Keys KeyCode: the keyboard code
· Keys KeyData: the key data (i.e. the key that was pressed, combined with
modifier flags that indicate which combination of CTRL, SHIFT, and ALT
keys was pressed at the same time.)
· int KeyValue: the integer representation of the KeyCode property
KeyPress events offer a KeyPressEventArgs with amongst others these key information properties:
· char KeyChar: the character (with correct casing)
The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events.
The typical use would be to process KeyDown to handle special keys (such as Enter, Backspace,
and CTRL/X combinations), and to process KeyPress to consume regular keys (as in adding
characters to text)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
How do a set a timer to a function in my windows form?
that it will run ( for example every min )
tnx mates!! 
|
|
|
|
|
Simplest way: Drag a timer object on your form, set up event handler for tick event and in the event handler call whatever method you want
|
|
|
|
|
how to fire application_end
application_start gets called
but end is not firing
what should i do
thanks
|
|
|
|
|
You should ask questions like this in ASP.NET forums, not here
|
|
|
|
|
Application_End gets called when the application ends, i.e. when the worker process that is running it terminates. To test it's working, put some code in it to write to the event log and then recycle IIS using iisreset.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi,
i'm writing an addin for VS2005 and need to replace some code in a document.
So far this works using the replacetext on a projectitem.document.
But i can't replace the code in a document when the text in the editor is collapsed, like with a region. a plus sign appears then.
expand it manually and run the addin seems to work...
i tried expandview but that also doesn't work. i suppose this one is for the treeview and not foor the document content.
Thx for your support
Kurt
|
|
|
|
|
Okay i found it myself.
file.Document.DTE.Find.Action = vsFindAction.vsFindActionFind; //vsFindActionReplace;
file.Document.DTE.Find.FindWhat = line; //line is my text
//file.Document.DTE.Find.ReplaceWith = TmpLine; // is my new text
file.Document.DTE.Find.Target = vsFindTarget.vsFindTargetSolution;
file.Document.DTE.Find.MatchInHiddenText = true; // default on.
vsFindResult tmp = file.Document.DTE.Find.Execute();
this opens the collapsed regions in a document.
Greetz
Kurt
|
|
|
|
|
how are you everybody ?
i would like to ask what is the most suitable method for creating chat rooms , to use multicast or unicast methodology ?
and if it is multicast how can i assign a globally reachable multicast address for the server machine
knowing that yahoo uses unicasting in chat rooms ?
uuuh , Yahoo guys are incredible , what about the overhead on the servers , how could they solve it ?
Human knowledge belongs to the world.
|
|
|
|
|
Hai Everybody,
Can any one suggest me, how to get the context menu while clicking only on the columns in the list view.
If the items is clicked then the context menu should not be displayed.
Best Regards,
M. J. Jaya Chitra
|
|
|
|
|
You can respond to the columnclick event and show context menu but the problem is that the event occurs when left button is clicked and not the right one. You will also have to figure out where to show context menu.
|
|
|
|
|
Hi,
How may I use following Dos command?
MKDIR ABC123
Thank you in Advance
|
|
|
|
|
M Riaz Bashir wrote: How may I use following Dos command?
MKDIR ABC123
Why would you want to? Look in System.IO and look for DirectoryInfo
|
|
|
|
|
|
i have a txt file with 1000 names and a table with two fields, id and NAME.
i want to read the contents from the txt file line by line and insert each line to the name field of the table..
how can i implements this using c#..
George Mathew
|
|
|
|