I am porting an MFC application to .NET WinForms. In the MFC application, you can right click on a menu or on a context menu item and we show another context menu with diagnostic and configuration items. I am trying to port this functionality to .NET, but I am having trouble.
I have been able to capture the right click, disable the clic...
I have a RichTextBox in .NET WinForms. I have been hooking up hot keys with KeyUp. Everything is working fine, except for CtrlI. By the time my handler gets its turn, the selection has been replaced with a '\t'. I turned off ShortcutsEnabled, but it didn't make any difference. Any ideas?
...
i have an ico file that contains a 48x48 and a 256x256 Vista PNG version (as well as the 32x32 and 16x16 versions). i want to draw the icon using the appropriate internal size version.
i've tried:
Icon ico = Properties.Resources.TestIcon;
e.Graphics.DrawIcon(ico, new Rectangle(0, 0, 48, 48));
e.Graphics.DrawIcon(ico, new Rectangle(48, ...
I have an object that starts a thread, opens a file, and waits for input from other classes. As it receives input it writes it to disk. Basically, it's a thread safe data logging class...
Here's the weird part. When I open a form in the designer (VS 2008) that uses the object the file gets created. It's obviously running under the d...
How does one lock the focus of a .net application to a specific control? For example, if I have a form with 5 text boxes, and I want them filled out in a specific order, how can I stop someone who is in box 1 from tabbing/clicking to box 2, or hitting OK or Cancel or anything else? Is there an easy way, or do I have to manually disable...
Is it possible to create a toggle button in C# WinForms? I know that you can use a CheckBox control and set it's Appearance property to "Button", but it doesn't look right. I want it to appear sunken, not flat, when pressed. Any thoughts?
...
The PropertyGrid control is very useful for editing objects at run-time. I'm using it as follows:
Form form = new Form();
form.Parent = this;
form.Text = "Editing MyMemberVariable";
PropertyGrid p = new PropertyGrid();
p.Parent = form;
p.Dock = DockStyle.Fill;
p.SelectedObject = _MyMemberVariable;
p.Prop...
I’ve started using the MVP pattern in a Windows forms app for a couple of my forms. These forms create a presenter and pass themselves back to the presenter.
I’m not using any particular framework and forms are still able to open other forms.
Should I change this setup so that presenters can open other forms (via views)? I believe wou...
I know this question had been asked more than a few times, but so far I haven't been able to find a good solution for it.
I've got a panel with other control on it.
I want to draw a line on it and on top of all the controls in the panel
I came across 3 types of solutions (non of them worked the way I wanted) :
Get the desktop DC and ...
I have a toolstrip containing, among other things, a ToolStripComboBox and a ToolStripButton. I want to add a ContextMenuStrip to both of them, but I don't have direct access to the toolstrip or its other contents, so I can't set the context menu of the toolstrip.
Setting the ContextMenuStrip for the ToolStripComboBox is easy:
myToolS...
I would like to add a backcolor for specific line depending of a Property of the object binded.
The solution I have (and it works) is to use the Event DataBindingComplete but I do not think it's the best solution.
Here is the event:
private void myGrid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
...
I am writing a quick and dirty application that reads all the files from a given directory. I'm currently using the OpenFileDialog to choose a directory and just culling off the file name that it provides. It seems like there should be a way to just choose directories though, but in a quick browsing of MSDN I didn't find it.
If you ...
I've got a Windows Forms application with two ListBox controls on the same form.
They both have their SelectionMode set to 'MultiExtended'.
When I change the selection of one the selection of the other changes.
Now I thought I'd done something stupid with my SelectedIndexChanged handlers so I removed them and re-wrote them from scratc...
I'd like to use the DataGridView control as a list with columns. Sort of like ListView in Details mode but I want to keep the DataGridView flexibility.
ListView (with Details view and FullRowSelect enabled) highlights the whole line and shows the focus mark around the whole line:
DataGridView (with SelectionMode = FullRowSelect) displ...
Our Windows Forms application by default saves data files in a user's 'My Documents' folder (on XP) or 'Documents' folder (on Vista). We look up this location by calling:
Environment.GetFolderPath( Environment.SpecialFolder.Personal )
We know for sure this works great for users whose personal folder is on a local disk. What we're not ...
I have a c# winforms program and it opens up a serial port. The problem happens when the end user unplugs the usb cable and then the device disappears. After this the program will crash and want to report the error to microsoft.
Is there a way to capture this event and shut down gracefully?
...
I need to bind labels or items in a toolstrip to variables in Design Mode.
I don't use the buit-in resources not the settings, so the section Data is not useful. I am taking the values out from an XML that I map to a class.
I know there are many programs like:
http://www.jollans.com/tiki/tiki-index.php?page=MultilangVsNetQuickTourForm...
Note: Question http://stackoverflow.com/questions/220465/using-256-x-256-vista-icon-in-application deals with using a "Vista" icon as the application's icon. This question deals with manually painting a Vista icon.
Note: Question http://stackoverflow.com/questions/281999/winforms-net-20-how-to-paint-with-the-proper-icon deals with paint...
From time to time my applications GUI stops redrawing.
There a lot of threads that are firing all kinds of events (like timers or network data ready etc.). Also there are a lot of controls that are subscribing these events. Because of that, all the event handlers play the InvokeRequired/Invoke game.
Now I figured out that when the GUI fr...
Vista has introduced a new API to display a text in the list view control when it doesn't have any items. As the MSDN library states, I should process the LVN_GETEMPTYMARKUP notification.
In the inherited ListView control the WndProc method is overriden:
protected override void WndProc(ref Message m) {
try {
if(m.Msg == 78 /* WM_...