winforms

How to prevent font resize when changing the DPI of the system

I have developed an application in C# .NET 3.5 and I would like it to maintain the same window size and font size even when the system DPI is changed. I've set AutoscaleMode to None in the main form. The form and controls are not resized but the size of all the texts is upscaled. Is there a way I can prevent texts to upscale or how can I...

Retrieving an accurate string array from a RichTextBox control

Guys, I have a RichTextBox control on my form. The control is setup in such a way that it will wrap to the next line after 32 lines of text are input. The problem I'm having is I want to be able to retreive an array of strings representing the lines in my control. I know there is a Lines property attached to the RichTextBox, but I am ex...

Flash ActiveX API documentation?

I am trying to put a Flash ActiveX control into a Windows Form but I am running into a problem: a lack of documentation. The best I have found is a site called "F-IN-BOX" that has some documentation but much of the API is still a black box. For example, some property will take an integer or a string and provide no clue about what it wa...

Initiate Properties automatically using StructureMap

If i have N numbers of classes on each of them i am declaring for example property which contains some app setting values from config file. public static IAppSettings AppSettings { get; set; } I want to populate this property automatically when class is created. I am thinking to achieve this goal using StructureMap. I want to "sa...

WinForms: there is no disk in the drive. please insert a disk into drive.

I have a WinForms application. It's written to disk. I run the application from disk and eject the disk from CD. Then I take the exception: there is no disk in the drive. please insert a disk into drive. How can I catch this exception and correctly close my application? ...

c#: Adding value to label

How when I click my datagridview command is run? Int64 sum = 0; foreach (DataGridViewRow dr in dg_Cheque.Rows) { if (Convert.ToBoolean(dr.Cells["True_False"].Value) == true) //Cells[0] Because in cell 0th cell we have added checkbox { sum +=Convert.ToInt64(dr.Cells[0].Val...

Cannot select checkbox in a databounded DataGridView

I've a DataGridView which is working perfectly fine. I use it just to show data. Now I want ability to select rows by check box and perform an operation for only selected rows on click of a button (this button is out of the grid on the same form). For this purpose, I'm following these steps to add checkbox column to datagridview. On...

Imitate disabled appearance of win forms control without actual disabling

I need to set appearance of a control to make it look like disabled control with grayed text and background. Is it possible to imitate disabled appearance of some control (for example of a button)? The appearance should be exactly the same as when I'm setting the 'Enabled' property to false. ...

Send keystrokes to Java applicaiton in Windows

Hi, I'm running a java application from within a C# application. My goal is to fill a couple of input boxes inside the java app automatically using the C# code. I assume the java application uses Swing for its UI. I've tried using SendMessage and WM_KEYDOWN but nothing happens. Since it's a swing app, the input doesn't have a handle, s...

extract wsdl from c# winforms client

Hi I have a client that was successfully calling a webservice. the webservice was changed then the changes removed. but now the compiled c# winforms client cannot call the webservice. Can I extract the wsdl the client is expecting to compare with the actual wsdl??? ...

DateTime issue - value available outside object but not inside

This is a very frustrating and bizarre issue and I would appreciate any advice on how to resolve it. I have an object with a private variable: private DateTime _maturityDate = DateTime.MaxValue; It has a corresponding property: public DateTime MaturityDate { get; set; } I have a method which updates the data in the database calle...

Display window on top of other windows, but not the task bar.

My application pops up a custom dialog whenever new items are found in an RSS feed, the custom dialog starts off the bottom of the screen, raises up, pauses, and then drops back down. I want the dialog to be on top of other windows (because the notices are important to me), so I set the TopMost property on the form to true. Problem i...

InvokeMember is very slow, anyway to avoid this?

I have to do reflection and late binding so i don't know if there is a way to speed things up. Thought I would give it a shot. This snippet takes about 15 seconds to complete which is way too slow, but seeing how I need to read the metadata. private static object InvokeCall(Type HostObjectType, Object HostObject, CallType callType, st...

How does one inject resources into an already built executable

I am working on a windows application that will need to be branded. The client will be selling this to other businesses, and needs a customized logo and name for each sale. The client does not know how to use visual studio! I think I need to write a packager app to inject custom logo and string resources into the executable. I am plann...

Recursive Invocation: Poor Style?

Below is a rather frightening pattern I sometimes use as a lazy way to do simple invocation. This code makes me feel slightly guilty, even though I'm not sure why. Is this horrifying? Reasonable? Going to blow up in my face later? public void myMethod(object args) { if (InvokeRequired) { Invoke(new MethodInvoker(delega...

How can I Remove registry entries on UnInstall (Install was done with Windows Installer)

I have a small WPF application that writes some basic information to the registry during program execution. The application is packaged with Windows Installer. How can I tell the Windows Installer to uninstall registry entries that were created during program execution when the program is uninstalled through the control panel? (Also no...

Dynamically removing column from datagridview

I'm binding dataset to datagridview, and I want give user possibility to removing(maybe by checkbox ?) columns which he doesn't know to see. So, at start he see 5 columns, and he wants look only at three, so he clicks at something and these columns dissapear. What are you using to give user this functionality? ...

Rapid Data Entry Database Connection Management

What is the best approach to connection management in a key data operator (kdo) type data entry (C# Winform) application with regards to database as well as client app performance? let's say the kdo is reading, editing, and writing back a table row every 5-10 seconds; should we open the connection and leave it open for the session (1000...

How to refresh DataGridView cells style

Hi, I have this simple piece of code on a windows form containing said DataGridView (dgvStatsTable) : public void LoadStatsTable(StatsTable statsTable) { dgvStatsTable.DataSource = statsTable.GetTable(); // returns a DataTable var smallFont = new Font(dgvStatsTable.Font.FontFamily, dgvStatsTable.Font.Size * 0.6...

DataGridViewComboBoxCell in an unbound DataGridView WinForm control

I am new to the DataGridView WinForm control and just do not like data Binding. I Used to use Spread OCX back 100 years ago and found it friendly. Now I am running into a problem try to do something simple: I have a grid with two columns: 1) Name 2) Status I want to loop through my collection of "ChinaVisas" and display the applicant's...