winforms

Prevent Blinking Cursor in Textbox

In a textbox, how can u prevent the display of the blinking cursor when you click on it? I did read in some forums that there is call to a particular api but when i tried it in my code, an error was shown. Please provide the complete code for this purpose if possible and let me know if there is a particular event where the code should b...

WinForms data binding - Bind to objects in a list

I need some help/guidance on WinForms data binding and I can't seem to get Google to help me with this one. Here is my scenario. Consider the following classes which is similar to what I need: public class Car { public string Name { get; set; } public List<Tire> Tires { get; set; } } public class Tire { public double Press...

Winforms generated events and removing the handlers

When creating form windows, often there are situations where a particular event was added and the program comipled.However later u realize that the event is not really required and so remove the event. Now when u compile the code again an error is displayed. For example in the code I have written: WindowsAplication1.LanMessenger does not...

sort icons on a listview (detail view) c#

When you see a details view and click the sort icon in windows, you already get the up and down arrow. How do you implement this is c# for listview? Also...How do you sort complex times like date fields in a listview? ...

Vista & C# - Drag & Drop problem (not related to elevation)

Application in question is .Net 2.0 Framework WinForms. It is supposed to work on large user base (installation from CD). Installation done using InnoSetup. On two machines, application does not accept Drag & Drop (both application and source of D&D have same elevation level). By adding Read & Read&Execute rights to INTERACTIVE SID for...

Why are my disabled buttons changing color?

My problem is: When my application is opened, I disable all buttons (in form_Load) and their color changes to the color of the background. But then I do some action (like clicking on a button), and in this action I disable the buttons again. Now some of these buttons become GRAY and others become as the background. Why is this? I don...

Transactions with typed dataset and Sql Server CE

I have a WinForms application that interacts with a SqlCe local database. I manage db operations using BindingSources, TableAdapters and typed datasets.I have several operations scattered through several methods in two different classes that I need to perform in a transaction and I was thinking of using System.Transactions.Transaction or...

How do you handle checks to see if a user changed something in a dialog

Talking .NET WinForms here: If you have an application where someone can change items using some properties dialog for example, how do you determine if a user has changed something when he clicks on cancel (to decide whether to display a cancel confirmation message box, or not). I can think of 2 methods: Defining a dirty bit and hand...

WinForms multi-threaded databinding scenario, best practice?

Hi, I'm currently designing/reworking the databinding part of an application that makes heavy use of winforms databinding and updates coming from a background thread (once a second on > 100 records). Let's assume the application is a stock trading application, where a background thread monitors for data changes and putting them onto the...

Changing the AcceptButton depending on active control

I have a working WinForm that handles the search functionality in my customer database. It contains the following controls: A textBox where you type your search string (A) A "search" button (B) A DataGridView (C) that returns the result of the search An "OK" button (D) and a "Cancel" button (E) What I am trying to accieve next is thi...

Format a databound label event

I have Windows Form application and a label which is databound based on a selection from a DataGridView. What I am trying to do is format the label text (which is filesize in bytes) after a new row in the grid is selected. How do I hook this up ? I tried using TextChanged but my formatting function is called twice, once for when the data...

C#: How would you prevent user from adding/removing lines in a TextBox?

How would you prevent the user from adding or removing lines in a TextBox? By that I mean, if I set the text in a textbox to 7 lines with some text, how can I make sure that it will always be 7 lines of text there? The user must be able to edit those lines like usual, but not remove a line entirely, and not add any new ones. Would have ...

Winforms MDI "Desktop" Area Boundry

The default MDI parent control has a large "desktop" area that can display multiple child forms. Users can drag forms to the edge of this desktop area so that most of the child form is off the screen. (A scroll bar then appears in the MDI parent) I don't like this feature. Is there a way to lock down the edge of the desktop area so tha...

Size/Location of Winforms MDI Client Area

Inside an MDI form is a client area that hosts the mdi child forms. How do I find out how big that area is? The best I can come up with so far is finding the total size of the parent's potential client area (mdiparent.ClientRectangle) and then subtracting off the sizes of components like toolbars, etc that take away from the client are...

How do you update a datagridview in C# every minute

I am working on a project in C# at the moment which is quite simple. I have a status box, two buttons and a dataGridView. When the Form loads the dataGridView is filled correctly. What I would like to do is then update that table every 45 seconds to reflect any changes in the database. I am looking for suggestions on a technique to ...

Visual C#, Winforms, and Partial Class Madness

Hello, I haven't done much work with .NET, so forgive me if this has a trivial solution. The "problem" (more of an annoyance, really) is that the VC# IDE opens all files that have a class which inherits from System.Windows.Forms.Form in design-view, by default. The only exception being "*.Designer.cs" files. Generally speaking, this is...

DateTimePicker-like Input Control

Hello, I'm not very experienced with .NET development, so forgive me if I've missed something obvious. My scenario is quite simple: my program is going to deal with both the Imperial and Metric systems of measurement. I need an input control that will be able to elegantly house {feet, inches} and {meters, centimeters} (only one set at a...

Change ToolStripPanel overflow behavior for dynamically added ToolStripItems

I have a Windows Forms ToolStripPanel that I dynamically add new ToolStrips to it. Each ToolStrip has ToolStripItems that I dynamically add to it (mostly ToolStripButtons). I would like to have all the ToolStrips fit on one row as long as you can see all the ToolStripItems in each ToolStrip. If adding a new ToolStripItem to a ToolStrip...

Design of a C# Windows Form App

I have a c# windows form app in which we did a rapid prototype for the client. The extent of my c# experience has been with ASP.NET/C# so its a bit different when it comes to the actual structure of the software. Time is a factor in this project since it is a school project and we have a little under 2 months to be done. The software wi...

NullReferencException when setting a Registry Value

I am getting a NullReference Exception when I try to set a value to a registry key. Below is my code. Does anyone know why? using System; using Microsoft.Win32; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(...