winforms

How to detect previous state of text field in C#?

I'm coding a simple text editor using Windows Forms. As in many editors, when the text changes the title bar displays an asterisk next to the title, showing that there is unsaved work. When the user saves, this goes away. However, there is a problem. This is handled in the change event of the main text box. But this gets called too when...

Windows Forms class partial public issue

Hello everyone, I am using VSTS 2008 + C# + .Net 2.0 to develop Windows Forms application. I found by default, the new Form we created will be marked as public partial. My concern is whether expose class as public has any security risks? Should we mark it as private? Any impact for functionality if we mark it as private? BTW: I met wi...

How do you fix the height and width of a winforms label to accept variable length text.

I have created a wizard form and each page of the form will display some help text. I either need a 1.Label control where I can fix the height and width of the label so it doesn't grow to long but rather wraps the text inside my fixed width and height. But a label doesn't have sizing handles and seems to automatically adjust to th...

Office Preview Handler

Hi, I am using Stephen Toub preview framework (http://msdn.microsoft.com/en-us/magazine/cc163487.aspx) to generate file preview in my win form application. If i run more than one instance i noticed that for word documents the application wait till the last word document completed the preview and only then starting to display the second...

C# DateTimePicker - Bolded Dates!?!?

Is it possible to set a series of bolded dates for a DateTimePicker control in a C# Windows Forms application?! Kind regards, ...

ALT+<shortcut> precedes KeyPress events on custom textbox winform control

Hi, I'm having a rather tricky problem that I'll try to explain as good as possible. The control is a textbox built from scratch. It inherits from System.Windows.Forms.Control. Now, on the form, I have a few other controls with the & shortcut (ALT+). When a non-input control is focused in winforms, you can exclude ALT in these shortcu...

Is it possible to avoid Focus on SplitContainer?

The WinForm SplitContainer gets the focus when it's dragged or clicked, while the Splitter does not. The side-effect of this, is that dragging a SplitContainer bar fires Leave/Validate on other controls, and I need to avoid this. I already tried setting TabStop and CausesValidation to False, but with no success. Is there a way to stop...

.Net authentication for both web and winforms

I have an ASP.NET web application I built for a client that uses default the ASP.NET forms authentication. They are now requesting a desktop (WinForms) app that works "with" the web application. I have created the webservices to access the data they want from the web app and put it into the desktop app. That works great.. but there needs...

C#/Winforms: sorting a datagridview by a column that is not part of the DataSource

I have a datagridview that has its datasource linked to a databinding from a database. All the columns are sortable by doubleclicking the header. Now I added one extra column by hand that just contains numbers. Strangely I cannot sort the datagridview by this column. If I doubleclick the header nothing happens. I have set sortmode to...

How to I find the space a combo box needs to show all list items.

I have a WinForms combo box, I wish to set the width of the column box so that any selected item can be shown in full. (I do not know what items will be in the combo box at the time of writing the software) However when I call Combobox.PreferredSize, it does not seem to take into account the items that are in the drop down list. ...

Strategy for keeping semi-static data fresh

I'm working on a winform app that will be used by groups in the US and overseas that replaces an existing app built with older technologies. Performance of the old app overseas is pretty slow due to excessive calls back to the database server in the US, so I'd like to cache as much stuff on the client as possible. What is the best way...

best way to find end of body tag in html

I'm writing a program to add some code to html files I was going to use a series of indexof and loops to find what is essentially ""X (where X is the spot im looking for) It occurred to me that there might be a more eloquent way of doing this does anyone have any suggestions. what it looks like currently <body onLoad="JavaScript:top...

c# threading and databases

hello, I've got a winform with some child forms on it. Now I'm accessing the child forms by a treeview in my main form. Now in that treeview is a list of websites. Since a website is actually a group of pages, this is also shown in the tree. Website is my parent and the pages are the childs. When you click on one of the pages the stati...

Why is Windows.Forms in System and not Microsoft?

I always had the idea that the root namespace in .NET, "System", was mainly for stuff that didn't depend too much on a particular platform. I was wondering if anyone had any ideas or insight as to why the Windows.Forms namespace is in System and not Microsoft since it seems to be fairly entrenched in one platform. (No flame wars or un...

Winforms Timer for Dummies

I'm trying to get a timer to tick once a second in a winform, when I look for advice on how to do this I find loads of stuff about threads. Well I don't care about threads, because all I'm trying to do is make a value count down from 60 to 0 in one minute, then stop. I don't think we need to go into cloud computing to solve this one, but...

How do I handle an exception caused by double-clicking between rows in a DataGrid?

Our DataGrid-heavy application likes to throw exceptions when double-clicking the space between rows used for resizing. The exception is The " DataGridColumnStyle cannot be used because it is not associated with a Property or a Column in the DataSource. Most of our DataGrid-based forms inherit from one form called GridForm. Our DataSo...

How to get the size of the drawing area of a Windows Form?

Hello, How does one get the size of the drawing area in a Windows Form? The Size, Width and Height properties return it for the entire form, whereas I'm looking for the area marked in the linked diagram by the white arrows: http://imgur.com/RhpZv.png Thanks! ...

Is there a way to paint semi transparently on a PictureBox?

I use a transparent background for the PictureBox control. But I also want to be able to paint with a %50 opacity blue FillRectangle. How to do this? ...

Databound radiobutton list in WinForms

This seems like this should be a pretty standard winforms control. Basically a combination of the listbox and CheckedListBox.. except with radio buttons. Does anyone know of a control I can download or is there a way to do this using the listbox or CheckedListBox? ...

How can you determine whether a form has been closed by the user or by your code?

I have a form (let's call it parent form), from which another "always on top but not modal" form can be loaded (Like a dialog but not a dialog - user can leave the new "child form" where it is and continue to work on the parent form). The first time the user opens that child form some data is loaded and displayed. Should they close the...