winforms

How to get a form to refresh when there's intense code working in the background?

I have a Windows form that I'd like to be able to refresh with a status of the work that's going on in the background in different threads. Problem is, even if I change the label on the form, it doesn't immediately refresh; it seems that the work happening on the other worker threads is preventing the screen from updating. How do I for...

C# GUI macro libraries or general approaches?

In a C# WinForms application (on .NET 3.5, probably 4.0 soonish), how would you go about allowing the user to define their own macros? For instance, a user could want the key press CTRL+K to mean clicking a certain item in the menu, and entering some text in the dialog opened by the menu, before pressing "Ok" to close the dialog. Ideall...

Handle the KeyDown Event when ALT+KEY is Press

Hi, AnyOne knows how to do this in .NET? ...

C# Winforms - Prevent a control from stealing focus when added programatically

Hi there. I have a bit of an odd question. My situation is as following: I have a form, It contains several user controls that in turn contains either other user controls or other basic controls such as TextBox, RichTextBox and such. As part of the logic when editing the text boxes, I create another control programatically and inform ...

C# WinForms Passing Dictionary from Static Class To Non-Static Form Class.

If I have a dictionary in a static class that gets updated randomly with data, how do I then pass this dictionary to the main form to display it in a grid view if the mainform is not static? Surely if I create a new instance of the mainform I will have multiple mainforms everytime I try and do this (every 15 seconds) and I will lose data...

DataGridView and the CellEndEdit Event

I have a DataGridView, and would like to hook into the CellEndEdit event. I've been able to successfully hook into the CellContentClick event, but am having issues with CellEndEdit. I added the following code to my Form1.cs file: private void dataGridView1_CellEndEdit(object sender, DataGridViewCellCancelEventArgs e) { ...

Availability of windows form during processing

I'm doing an application that does some sort of scanning (it checks availability of URL's through a short list) and depending on the result, it adds to one or another listbox. if it exists, it goes to lstOK, else, it goes to lst404. The issue is that these web checks take time (specially when it is OK), it takes an awfully long time, an...

How do I specify the type of the range variable in a LINQ query?

How do I specify the type of the range variable in a linq query? ...

Control.invoke and parent control

Hello, Lets say I have a form called MainForm and a control on it: somelabel. In order to access these controls from another thread I have to use Invoke method. e.g: somelabel.Invoke(...); However I can also access the label through the form like this: MainForm.Invoke(...) //Code for manipulating somelabel Is there any difference ...

How to restore a minimized window using AppActivate(ProcessID)

The documentation for AppActivate(ProcessID) states... The AppActivate function changes the focus to the named application or window but does not affect whether it is maximized or minimized. Unfortunately, it doesn't then advise how you CAN un-Minimize an application from the task bar when you want it activated. I can't fin...

What happens to controls created in a method after the method is done?

for example in this code: void ButtonCreator() { Button elboton = new Button(); } what happens with elboton after I call this method? ...

WinForms performance mystery: derived PictureBox control slower than the original?

In my .NET 2.0 project, I made an empty derived class of System.Windows.Forms.PictureBox: public class NewPictureBox : PictureBox { //absolutely nothing } Then I did the following: set both the derived control's and the base control's Image property to a rather large image (800x600), SizeMode is Normal (only the upper-left port...

How to set win forms datetime picker to have no default value??

Hi everyone. I am implementing search functionality in WinForms and I search by date range. Thus there are dateForm and dateTo date pickers on the form. By default their values are date time now() and if user do not touch date time pickers at all he will not get any results. Because search will be performed between now() and now(), also...

can't exit a windows c# forms application

I am working on learning Windows Forms with C# and have a bare bones application. I am trying to close it when the user selects File->Exit. I have an event handler attached to it and I have tried calling Application.Exit(), Application.ExitThread() and just closing the form. Nothing. It stays there. I'm not creating any other Threads of ...

how to dynamically add combobox in windows forms(C#) and bound it to a column of a table in sql database

My windows form has an ADD button which adds a combo box to the form after each click. The problem is, i am not able to bind it to a table column at run time. Using an existing databinding source selects the same value in all the combo boxes. I am coding in C# here is the sample code ComboBox ocbNext = new ComboBox(); //HAVE set the r...

NHibernate Design For WinForms

How should I have the NHibernate Session Factory and the sessions for a WinForms application? Should the SessionFactory be a singleton? Or can I create it every time? What about sessions and transactions? Any help would be appreciated. Thanks ...

Output control in Bitmap

I want to implement previews/thumbnails in my project, therefor i need the graphical output of a control as bitmap. I have a third party control which loads documents and displays them. Is it possible to fetch the output of an control and store it in a bitmap object without adding it to the UI? And If how? Edit: I probably should said t...

Moving from WinForms to WPF

Well we are considering to move from WinForms to WPF, what pitfalls does WPF have? And we got component one's flexgrid is there any wpf grid that has the same functions? one nice thing with it is that you can implement your own draw method for the cells... It can merge cells print and save to many file formats.. ...

DataGridView - how to set column width?

Hello fellows, I have a WinForms application with DataGridView control. My control has five columns (say "Name", "Address", "Phone" etc) I am not happy with default column width. I want to have more control over column appearance. What I want is to be able to do one of the following: Set width of each column in percent Set width of e...

WinForms: Autocomplete in multiline textbox

Does anybody know of any solution how to provide autocompletion suggestions (say to help input keywords from a list) for a multiline WinForms TextBox/RichTextBox? For a single line textbox, this is very easy. Multiline is obviously not implemented directly by Winforms. ...