winforms

ComboBox exception caused in winforms FormClosing event

Using c# vs2008 winforms I have an application with a bunch of child winforms. Each time a form is closed I need to store the current selected value of a combobox that is on each form to a Global application variable so that I can track it and use it in new forms. The combobox is populated on form start via a method to set its datasourc...

Using a "hyperlink" effect in Winforms applications

What do people think about using pretend hyperlinks, in Winforms apps? Example: In my example you would click "into" the Organisation record card for Acme Corp Inc or "into" the details of the next appointment. If we ignore, for the moment, how the user edits the Organisation or adds/removes an appointment, is it a sensible UI in W...

Does The Dialog ID change?

Hi, Does the Dialog ID change from one machine to another? ...

Is there a quick way of selecting all items or inverting the selection in a ListView?

I can quickly clear the selection of a ListView using its SelectedIndices.Clear method, but if I want to select all the items, I have to do this: for (int i = 0; i < lv.SelectedIndices.Count; i++) { if (!lv.SelectedIndices.Contains(i)) lv.SelectedIndices.Add(i); } and to invert the selection, for (int i = 0; i < lv.Select...

unable to edit DataGridView populated with results of LINQ query

When i use the results of a linq-to-xml query to populate a datagridview, i cannot edit the datagridview. i've tried setting the datagridview's readonly property to false and that doesn't help. I also added an event handler for cellBeginEdit and put a breakpoint there, but it doesn't get hit. Any idea what i'm doing wrong, or if this ...

How do I increase the size of start run command line to increase the target

I am passing parameters from start-run to my windows application. What I came to know is that you cannot pass more than 259 characters . I have an windows application in C# where I want to pass arguments. Initially I gave as commandline arguments, using the enviorment.getcommandlineargs, which did work successfully. Now the client made a...

Custom Formatting Double

I have a DataGridView bound to a DataTable in a DataSet. I set all columns of the DataTable to System.Double. I want the last row of the DataGridView to display "PASS" or "FAIL" depending on some condition of the values in that column. How do I do this? Ideas: lastCell = IIF(condition, Double.PositiveInfinity, Double.NegativeInfinit...

Manage Z-Orders of windows in different threads/message loops?

I've got a C# SCSF application using Telerik WinForms UI conrols that has some long running UI operations that lock up the main UI thread for a few seconds. I do as much background processing on background threads as I can, However some of the databinding and list loading operations cause up to a 5 second halt on the UI Thread. In orde...

How to get the height of Label control in Winforms

My label is wrapping the text due to the length of the text. The height property returns the correct value only if there is a single line. How can I get the correct height? Thanks. Solution: I was creating the label dynamically and checking the height then. Later the panel on which the label was residing was added to a form, changing t...

How to immediately exit a Windows Form .Net application?

In our app, we have a quite extensive exception handling mechanism. At some point in our error handling logic, we want to terminate the application -- right at this point with no further code execution. Our current code use Environment.Exit() to do that. After a call to Environment.Exit(), some code is still executed. For instance, the G...

What's the difference between Application.Run() and Form.ShowDialog()?

In my application I want to show a login form first and then the main form if the login has been successful. Currently I'm doing it something like this: var A = new LoginForm(); if ( A.ShowDialog() == DialogResult.OK ) Application.Run(new MainForm()); But then I started wondering - what's the point of the Application.Run()? Why no...

setting position of a control doesn't seem to work when scroll is 'moved' (c#, winforms)

Hi, Description of the problem: Create a 'custom control'. Set it's property AutoScroll to 'true'. Change it's bg-color to green. Create second 'custom control'. Change it's bg-color to red. On main form place first custom control In code create 20 instances of second control Add a button and in the button: In code set their position...

Using multiple tables with ADO.net and C#

I've just started working with Visual Studio and C#, and am trying to solve a small problem I have. I come from a Microsoft Access background, and have quite a bit of experience with database queries and forms. However, I am currently trying to re-implement an access database with C#, ADO.net, and Windows Forms. Visual Studio makes it...

Proper way to override Control.ControlCollection

I went about creating a custom TabControl widget so that I could accurately paint the tab with a close X on the right edge of the tab. I have a custom array class that holds all of the tabs. So I override the CreateControlsInstance instance class and redefine the Controls class so I can hide it during reflection serialization. prote...

C# winform - playing wav files from embedded resource

I have 15 1-second wav files, that need to play one every second, for 2 minutes. Is it better to read the wav files into memory at application load and play from there, or load on the fly from Properties.Resources each second? ...

How to make thread-safe calls to windows forms controls.

Yes, I have read about the MSDN article: How to: Make Thread-Safe Calls to Windows Forms Controls It said I should use async delegate to make the call. But why does the async delegate make the call safe? I only know the how-to but not the reason. Could someone shed some light on me? Many thanks. ...

Start a process TopMost.

I have a C# .Net 2.0 app which implements a FullscreenMode like this: targetForm.WindowState = FormWindowState.Maximized; targetForm.FormBorderStyle = FormBorderStyle.None; targetForm.TopMost = true; WinApi.SetWinFullScreen(targetForm.Handle); // let me know if you need the code of this methode If the user is in FullscreenMode and tri...

Multi resolution

How To make user Control run on multiple resolution it run will on resolution 1366 X 768 but when I try to run it on 800 X 600 part of it did not appear , wheteherI docked it on the main form ...

How to add help to winform c# application.

I want to know that how can I add help support to my winform app. How do I create chm file for help and how do I integrate it with the application. I want help for almost every control in my application. ...

Checkbox on Datagrid with auto-generated columns, how to pass check-state to source without row change?

I have a windows form with DataBound DataGrid on it. Bound to a list of objects. One of the objects property's is a boolean. So the grid shows it as a Checkbox. When I click on the check box the tick appears or disappears but does not update the underlying data, until I change rows. This is a bit counter intuitive, is there fix? ...