天道酬勤,学无止境

winforms

Calling a form from a string in c#

I have a Windows Application in C# and I need to call a Form whose name is saved into a string variable in run-time. Like; I already have the form; Login.cs string formToCall = "Login" Show(formToCall) Is this possible ?

2021-06-15 17:55:27    分类:问答    c#   winforms

How can I use the Windows look'n'feel for a system tray context menu?

I'm working with a NotifyIcon and ContextMenuStrip, I don't want to use the default menu look and feel which is shipped out of the box with this control which is different to Windows (Vista in my case) by using contextMenu.RenderMode = ToolStripRenderMode.ManagerRenderMode or contextMenu.RenderMode = ToolStripRenderMode.Professional: I don't want this using contextMenu.RenderMode = ToolStripRenderMode.System: I just want to use the standard, normal Windows "look and feel" as seen in countless, probably non-.net applications *grumble*: Any ideas guys on how to achieve this?

2021-06-15 17:32:21    分类:问答    c#   .net   winforms

NotifyIcon ContextMenu and too many click events

I'm using the NotifyIcon class to display an icon in the task tray. The icon performs 2 functions - when the user single-clicks with the left button it should display a window, when the user single-clicks with the right button it should display the context menu. This works fine apart from the window being displayed after the user clicks an option in the context menu. Here's my code: contextMenuItems = new List<MenuItem>(); contextMenuItems.Add(new MenuItem("Function A", new EventHandler(a_Clicked))); contextMenuItems.Add(new MenuItem("-")); contextMenuItems.Add(new MenuItem("Function B", new

2021-06-15 17:05:16    分类:问答    c#   .net   winforms   wcf

Using dispose() method instead of close() method to a form

What is happening when I close a form, which was opened using Show(), by using Dispose() instead of Close()? Can someone tell me in detail, what happening in the Dispose() method?

2021-06-15 17:04:45    分类:问答    winforms

Hiding Row in DataGridView Very Slow

I have a DataGridView in a Winforms app that has about 1000 rows (unbound) and 50 columns. Hiding a column takes a full 2 seconds. When I want to hide about half the rows, this becomes a problem. private void ShowRows(string match) { this.SuspendLayout(); foreach (DataGridViewRow row in uxMainList.Rows) { if (match == row.Cells["thisColumn"].Value.ToString())) { row.Visible = false; } else { row.Visible = true; } } this.ResumeLayout(); } I did some testing by adding by addingConsole.WriteLine(DateTime.Now)around the actions, androw.Visible = falseis definitely the slow bit. Am I missing

2021-06-15 16:17:51    分类:问答    c#   .net   winforms   datagridview

Parse c# class file to get properties and methods [duplicate]

This question already has answers here: Closed 8 years ago. Possible Duplicate: Parser for C# Say if I had a simple class such as inside a textbox control in a winforms application: public class Person { public string Name { get; set; } public int Age { get; set; } public void DoSomething(string x) { return "Hello " + x; } } Is there an easy way I can parse the following items from it: Class Name Properties Any public methods Any ideas/suggestions appreciated.

2021-06-15 16:07:25    分类:问答    c#   .net   regex   winforms   reflection

How to change WebBrowser control User Agent in C# [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago. I am a beginner in using WebBrowser Control in C#. I try to change the User Agent string in a WebBrowser control in my Windows form. How can i do this ? Please Help.

2021-06-15 15:22:05    分类:问答    c#   winforms   webbrowser-control

Accelerator (mnemonic key) are executed without pressing ALT key

I'm experiencing some troubles using mnemonic keys in Windows Forms: Simply having a form with a button, which uses ALT+s as the accelerator: this.searchButton = new System.Windows.Forms.Button(); this.searchButton.Text = "&search"; The button action is executed by simply pressing "s" (without pressing the ALT key). I have checked some other applications, and the accelerator actions are only executed when the ALT key is pressed. Is this a .NET problem? How could address this issue? Thanks in advance.

2021-06-15 14:19:19    分类:问答    .net   winforms   button

Prevent Win32 from drawing classic title bar

I wanted to add a nice shadow to my borderless form, and the best way I found to do it with minimal performance loss is to use DwmExtendFrameIntoClientArea. However, this seems to be causing Windows to draw a classic title bar over the window, but it is non-functional (ie. the glitch is merely graphical). This is the code I am using: int v = (int) DWMNCRENDERINGPOLICY.DWMNCRP_ENABLED; NativeApi.DwmSetWindowAttribute(Handle, DwmWindowAttribute.NCRENDERING_POLICY, ref v, sizeof(int)); int enable = 0; NativeApi.DwmSetWindowAttribute(Handle, DwmWindowAttribute.ALLOW_NCPAINT, ref enable, sizeof(int

2021-06-15 13:50:12    分类:问答    c#   windows   winforms   aero   dwm

How to delete selected Items from a ListView by pressing the delete button?

I want to delete one or more selected Items from a ListView. What is the best way to do that? I´m using C# and the dotnet Framework 4.

2021-06-15 13:19:51    分类:问答    c#   winforms   .net-4.0