winforms

How to view/monitor which events are being fired from controls on a user interface

I am creating an GUI using winforms in C#, all the controls have numerous events. I would like to know which of these events are being fired and when. One way would be to put debug statements on each of the event handlers but that would require too much work. Is there any way of doing this in Visual Studio 2008/2010 or are there any tool...

.Net WinForms TabControl Steals Focus on form activation

Hi Guys, I wonder if there is anyone who can help me? The issue I have is a windows form TabPage stealing focus upon form re-activation. The form has a TabControl with four or five TabPages. Each tab page has many various controls. The scenario is as follows: A user tabs through a few controls on the first TabPage and a new form is sp...

Getting error when printing to Local Printer

My users want to be able to print a report I've designed in VS 2010, directly, rather than doing through the process of previewing the report. I've designed the report in VS 2010, using the report designer there, which has created a .rdlc file. I'm using the following MSDN walkthrough as an example, for my code: http://msdn.microsoft....

Making a splash screen in C#

The concept of a splash screen doesn't strike me as something that should be so complicated, but I'm having trouble getting the whole splash screen painted. Let's say I have two System.Windows.Forms.Forms: RealForm and SplashScreen. The RealForm contains the initial GUI. During the RealForm's loading process (that is, in the event han...

Closing form from different thread happening too soon, causing exception

I've got the following situation, Private Sub MyButton_Click(sender as Object, args as EventArgs) Handles MyButton.Click Me.pleaseWaitFrm = New PleaseWaitForm() ' Fire up new thread to do some work in (AddressOf DoMyWork) Me.pleaseWaitFrm.ShowDialog() End Sub Private Sub DoMyWork() Dim log = Me.DoTheActualWork() Me.p...

Sequence of events and all hooks made available in System.Windows.Forms

Is there any explanation of the sequence of events that occurs in the creation, manipulation, and closing of System.Windows.Forms's various forms and components? Is there an explanation of all possible hooks that I can override and the order they are called in and what happens in between their calling? I've run into so many avoidable p...

Databinding multiple controls to a single LINQ query

I have a LINQ query I wish to run and drop the result into a var or IQueryable. However, I'm binding the result to multiple (4 to 10) controls and only want the query to run once. When I just put the result into all the datasource values, the query runs for every control and the controls (comboboxes, for example), change selectedvalue...

Winforms - Embedding form inside a form or container causes form controls to behave differently

EDITED: When I load a form dynamically inside another form or container control, the editing behaviour of all the form's components is different. Text editing, in a TextBox or ComboBox, does not allow me to select partial text with the mouse, though I can double click to select all the text in the control. FormChild form = new For...

Problem setting DataSource of a DataGridView

What happens here is when in the form opens, it shows the contextMenu and display the DataGridView on it with the value of dataSet1. But when I click the button to change the DataSource of the Grid, it doesn't show the records of dataSet2. private void Form1_Load(object sender, EventArgs e) { SetDataSource(dataSet1);// A populated D...

How can a new Form be run on a different thread in C#?

I'm just trying to run a new thread each time a button click even occurs which should create a new form. I tried this in the button click event in the MainForm: private void button1_Click(object sender, EventArgs e) { worker1 = new Thread(new ThreadStart(thread1)); worker2 = new Thread(new ThreadStart(thread2)); worker1.S...

visual styles independent drawing

Using C# winforms, i want to create custom controls that looks like the real ones. There are a lot of classes that can be used to draw controls that looks like the real ones: ControlPaint, VisualStyleRenderer, ButtonRenderer, CheckBoxRenderer, ComboBoxRenderer, GroupBoxRenderer, ProgressBarRenderer, RadioButtonRenderer, ScrollBarRendere...

How to fake mouse cursor position in Windows Forms C#?

I have this Windows Forms application with a simple balloon tooltip. Depending on the application's window location on the desktop and the mouse cursor location, the balloon 'tip' (or balloon pointing arrow) may or may not be pointing to the location I want. For instance, my app snaps to the desktop sides and when it's snapped to the ri...

button backcolor is lost when mouse not hovering over

I have a number of buttons on my frame and I want to show which one is selected by showing a background color. The only problem is that this background color is only visible when the mouse is hovering over the button, otherwise the button will be clear white. Overriding the MouseEnter and MouseLeave events didn't help. The button is in...

Automatically embed multiple icons in a .NET Executable

I basically have the same issue as this question: Embed multiple icons in WPF EXE My .NET 2.0 WinForms application currently has this when you click "Change Icon" in explorer: What I would like to see, and with some hacking about as suggested by the above article I get this: However the process of getting there all of the version ...

Dataset vs. Returning a Datatable

I have created alot of stored procedures in my application that return the result of a query in a datatable object. I never use a dataset. Why would I ever use a dataset over simply returning the result of a query as a datatable object? ...

how to add an event to a UserControl in C#?

I have a UserControl which contains 3 labels. I want to make an event for it, which occurs when the text of one of the labels changed. I am using Visual Studio 2010 ...

i'm writing a wrapper for cmd but am having trouble with redirecting standard input

OK so here is what I'm doing -- I want to write a .net app that redirects standard out / in to a richtextbox. I've got it working pretty well, but once I add standard input into the mix my read commands freeze up. Here is the relevant code from within my form. Shell = new Process(); Shell.StartInfo.FileName = "cmd"; ...

How can I edit a text file using C#?

Lets say i have a text file with following content: Hello! How are you? I want to call the file via a simple application that produces an output file with the following contents: buildLetter.Append("Hello!").AppendLine(); buildLetter.Append("How are you?").AppendLine(); As you see, every line should be put between " ". Any h...

is it possible to use style for .net winforms control ?

Is it possible to use style for .net winform control ? ...

ConfigurationManager looking for different files on different systems

I'm using configuration manager in the simplest way: Read: ConfigurationManager.AppSettings["Foo"] Write: Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["Foo"].Value = value; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection("a...