I have cloned the mainMenu to the context Menu. If I set the .Enabled or .Disabled in the form load event. These feature works properly. But If I minimize the form to use the contextMenu, the mnHide menuItem is not Hidden. If I click on Hide when the form is hidded, this causes the form to be squeezed to just the min, max and close buttons, when I do finaly hit the Show button.
Right now my issue is getting the mnHide button to hide, but this isn't working? Is there another way to hide the cloned context menu items ?
Wherever you cloned your menus, those mnShowClone and mnHideClone menus have to be accessible, i.e. if you declare them inside a method they will not be available inside another method. Instead, add them as class fields (just like mnShow and mnHide) and assign them if they haven't been assigned already (as part of initialization code or something).
Unbelievably, as easy as this may be, for myself it is still not working.
private void InitializeComponent()
... excess code removed
MenuItem mnShowClone = this.mnShow.CloneMenu();
MenuItem mnHideClone = this.mnHide.CloneMenu();
// MenuItem mnShowClone = this.mnShow.CloneMenu();
// MenuItem mnHideClone = this.mnHide.CloneMenu();
this.contextMenu1.Popup += new System.EventHandler(this.contextMenu1_Popup);
This will be possible in either .NET 2.0 or Longhorn (no sure exactly which since release details are still sketchy) with Console.Clear, but for now you have to rely on other ways. One article here on CP presents such a way: http://www.codeproject.com/csharp/winconsole.asp[^].
Portability is often not possible anyway. Say I write a console app to manage the NICs in the machine - unless I add an abstraction layer, managing information on the NICs / in the OS is platform-dependent. Even with the code I gave, one could always abstract that, too.
In any case, your idea works, it just isn't technically clearing the screen (this is most notable when you have a larger command/output buffer for your prompt and scroll).
is it possible to make a program in c# that doesn't require the .net framework installed?
I've written a program in c# and visualstudio.net and I want it to work without any trouble on all computers, but when i try to run it on my other computer it says that the .net framework isn't installed..
is it possible to include the framework parts that are needed in the program..
or is the only way to go to rewrite the program in c++?
C# compiles to IL (like all .NET languages) which is JIT'd and executed by the Runtime which managed the memory, code, bindings, etc., hence being called "managed code". What do you think is managing it?
A very generic question that is. i would like to know how i would go about launching an application with C#. And if it is possible, how could i manage it in simple terms (execute/restart/stop) not, managing it's contents etc.
i am populating combobox on keypress event of the combobox.
when three character are pressed, i get for the text so for written in the combobox and search the text in the database, after searching if results are found, combo-box is clear & populated again using a for loop ( since the result after the database query is an ArrayList).
Next i do this combox.DroppedDown=true,
Now here comes the problem, the selected text (i.e the characters that are written in the combox box are cleared), i have expilicity set the combo-box text.
other problem is when combo box is in dropped down mode, the first element get selected even if i don't want to .
please help if any one has solution
This is the behavior of the ComboBox common control, which the System.Windows.Forms.ComboBox class wraps. In order to override this sort of functionality, you should read about the ComboBox common control (in the "User Interface Design and Development" section of MSDN, under "Windows Controls") and extend the ComboBox class in .NET in order to override the WndProc method and handle the notification messages yourself. Some of this might be possible using managed events, but not everything always is.