winforms

multicolumn sorting of WinForms DataGridView

I have a DataGridView in a windows form with 3 columns: Serial number, Name, and Date-Time. The Name column will always have either of the two values: "name1" or "name2". I need to sort these columns such that the grid displays all the rows with name values in a specific order (first display all the "name1" rows and then all the "name2...

Modifying Export to Excel in ReportViewer to be readonly

I am working with WinForms, using C# and .Net 3.5: I have ReportViewer exporting to PDF and Excel. However I do not want the user modifing the Excel file after it has been exported. Does anyone know how to cause the basic functionality of the export to excel to lock the file down or to export it as an image into Excel? I have read This...

How to change the font color in the textbox in C#?

If I want to upload a text file into the textbox and want to highlight certain words with a font color change, how can I do that without drawing the text? Thank you. ...

Of Datagridviews, databinding, and non validating cell values.

Lets simplify. Lets say I have this class: class T { public string Name { get; set; } public int Age { get; set; } public int height{ get; set; } ... } and I have a DataGridView's DataSource bound to a BindingList <T>, with N columns, each one bound to each property. I need to: Allow the user to enter non validating age...

How to expand datagridview combobox cell programmatically?

I am trying to expand the ComboBox when users click it but I have had no success. This is what I have: private void dtgProductos_CellClick(object sender, DataGridViewCellEventArgs e) { SendKeys.Send("{F2}"); //dtgProductos.BeginEdit(true); does nothing! } Any advice on how to do this? ...

Control.IsAccessible

I need to check if a c# WinForm Window (FORM Class) has been initialized and waiting for user events. But I could not find out how to manage that. Therefore I had the idea to set the Control.IsAccessible Flag of the Form to true, within the OnLoad Event of the Windows Form. My question is now, what is the Control.IsAccessible Flag ori...

Is there a way to make a TreeView appear always fully expanded?

I have a TreeView on my form but I'd like it to always be fully expanded, even the child nodes. Is there a way? ...

.NET app running as either Windows Form or as Console Application

I am looking to have one of my Windows Forms applications be run programmatically—from the command line. In preparation, I have separated the logic in its own class from the Form. Now I am stuck trying to get the application to switch back and forth based on the presence of command line arguments. Here is the code for the main class: s...

Winforms connection strings from App.config

I have a Winforms app that I am developing in C# that will serve as a frontend for a SQL Server 2005 database. I rolled the executable out to a test machine and ran it. It worked perfectly fine on the test machine up until the last round of changes that I made. However, now on the test machine, it throws the following exception immediate...

Panel in Windows Forms Application not clearing

I'm working on my project: [Beer Pong Management System][1], a Windows Forms application. I am currently trying to add a whole tournament mode to it. In a nutshell, I've created a TabControl, with the first tab page with the settings and setup and the second page the brackets. There is a feature for each of the match-ups, that once ther...

How to build a windows/web application that stores data locally and sync's with remote database?

Hello, I am needing to build an application that stores data locally and then synchronizes with a remote MS SQL database. I am not sure how to go about doing this. Enter data offline on a form and store the data. Synchronize the data with a remote MS SQL database when online. There will be many users who enter data offline, the local...

Is there a WinForm control inspector application?

I'm looking for something that provides interactive meta-data about a running .NET WinForms application. Basically, I'd like to be able to hover over a running WinForms application and have the inspector highlight the various controls and let me inspect properties such as size, position, parent, etc. I could have sworn I've seen this s...

How to register a namespace in app.config

How can i register a namespace in app.config so that it will become globally accessible. ...

WinForm and WPF Form rendering

Hi, Pardon me, if it is a silly question. Can you anyone tell me how the WinForms are rendered (the background mechanism) Also how is WPF Form are rendered. In simple, i want to know the rendering mechanism of WinForms and WPF Forms. ...

Not able to select a Font file from Windows Fonts folder using OpenFileDialog

I am trying to use the .NET Windows Form OpenFileDialog control to select a font file (not a font as you would with the FontDialog), but the dialog will not allow a mouse click to select a file in the C:\WINDOWS\Font directory. Any ideas for choosing a font file ...

What is the difference between Invoking and BeginInvoking a MessageBox?

In a form, compare BeginInvoke (new Action (() => { MessageBox.Show ()); })); with Invoke (new Action (() => { MessageBox.Show ()); })); What is the difference, and when should I use one over the other? How is the behavior affected by the message pump of the MessageBox? I did some testing and found that both methods block ...

Difference in BackgroundWorker thread access in VS2010 / .NET 4.0?

Here's an interesting one - in VS2005 / VS2008 running against .NET 2.0 / .NET 3.0 / .NET 3.5, a BackgroundWorker thread may not directly update controls on a WinForms form that initiated that thread - you'll get a System.InvalidOperationException out of the BackgroundWorker stating "Cross-thread operation not valid: Control 'thecontrol'...

.NET WinForms INotifyPropertyChanged updates all bindings when one is changed. Better way?

In a windows forms application, a property change that triggers INotifyPropertyChanged, will result in the form reading EVERY property from my bound object, not just the property changed. (See example code below) This seems absurdly wasteful since the interface requires the name of the changing property. It is causing a lot of clockin...

Windows handle if a control is set to visible = false (.NET)

Hello, Quick question, do controls in .NET have handles (hWnd) if they are set to invisible? Marlon ...

How to honor/inherit user's language settings in WinForm app

I have worked with globalization settings in the past but not within the .NET environment, which is the topic of this question. What I am seeing is most certainly due to knowledge I have yet to learn so I would appreciate illumination on the following. Setup: My default language setting is English (en-us specifically). I added a secon...