winforms

WinForms controls are flickering when resizing on Windows7 x64

This very strange. When I resize a WinForms dialog the controls are flickering very bad, some of them are disappearing. It happens only when using the application under Windows 7 64. ...

Get last Month of selected check boxes

I have a for loop that check whether some checkboxes are checked foreach (CheckBox chk in this.Controls.OfType<CheckBox>()) { if (chk.Checked) { //Some code here } } There are 12 checkboxes, 1 for each month. What i want is to calculate the number of days between a variable StartDate and the last month. It's hard ...

how to make a property grid like context menu for button ?

how to make a property grid like context menu for button ? So when right click on button . property grid will be visible and when click some where else , that will hide. ...

Master-Detail via ComboBox in C#?

I have a form showing the details of a client (various controls), along with their orders (in a DataGridView). I am trying to add a ComboBox to let the user select one of the client's orders and display the items associated with it in a separate DataGridView. However, I cannot work out which DataSource/DataBindings I need for either th...

Dialog MessageBox sometimes hidden behind the main form

Some of our non-technical users are having problems where a dialog MessageBox in our application can sometimes be displayed behind the main form and the application does not accept any input until the messagebox (which they can't see) is dismissed. The application is written in C# and the message boxes are standard eg the code can be as...

how to take 6 numbers after the dot - but without round the number ?

hi how to take 6 numbers after the dot - but without round the number ? for example: 102.123456789 => 102.123456 9.99887766 => 9.998877 in C# winforms thak's in advance ...

Tooltip not showing for nested control

I have the following piece of code that works great in all but one instance. private void tbxLastName_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) { GetRemainingChars(sender); } public void GetRemainingChars(object sender) { var control = sender as TextEdit; var maxChars = control.Pr...

CellValueChanged vs CellValidating Events for DataGridView

Hello, What's the best place to implement validation logic code and conditional formatting code for a DataGridView? In a lot of books and articles that I've read on this control, it seems to suggest that the appropriate event to handle for this is the CellValidating one. Well, the name more than implies this as well. However, this eve...

Scroll bar greyed out when a Data Grid View is updated but not visable.

I have a custom control that is basically a DataGridView docked inside a split panel with a rich text box on the other half. This control is docked in a tab page in my main program. Here is some relevent code public LogReader() { InitializeComponent(); using (var conn = new SqlConnection(ConnectionString)) using (var ada ...

Winforms widget to display a grid of constantly updated numbers?

I'd like to create a Winform app (Mono support would be a huge plus) to display a grid of rapidly updating numbers, while not running into redraw problems while scrolling. From searching around I've found: Telerik GridView which seems to be exactly what I want. Is the Telerik path the way to go? Or is the capability available within ...

How can I update a winform asynchronously?

I've got a winform, and a bluetooth connection with a lego nxt brick. Now I want to update the form every second to read sensors or the battery level. But if I start a new thread for that, there i a invalid thread operation exception when the thread wants to set the label text. Can anyone help me? ...

Cross-thread operation exception when worker thread adds to BindingList

I have a worker thread that needs to add items to a BindingList. However, the BindingList is databound to a DataGridView. So, when I try to add to the list, I get an InvalidOperationException (Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on.) Normally for this exception you would ...

Is there a lot of overhead in a User Control?

I am working on a WinForms project which feels sluggish. It is composed of a literally hundreds of User Controls. If there is a piece of a UI functionality (even if not used anywhere else in the app), it's encapsulated in a User Control. I've gone through the project a number of times with the ANTS profiler and most of the heavy code a...

C# Drawing on Control at Design Time

I'm drawing a rounded rectangle on a control. At first I was only binding a paint handler to the Paint event at runtime: this.Paint += new PaintEventHandler(Panel_Paint); Then I figured out I can just override OnPaint which should then cause the drawing at design time, too: protected override void OnPaint(PaintEventArgs e) { bas...

It is possible to copy all the properties of a certain control? (C# window forms)

For example, I have a DataGridView control with a Blue BackgroundColor property etc.., is there a way which I can transfer or pass programatically these properties to another DataGridView control? Something like this: dtGrid2.Property = dtGrid1.Property; // but of course, this code is not working Thanks... ...

How to set the DataSource of a DataGridView inside a ToolStripControlHost? (C# window forms)

I have a DataGridView inside a ContextMenu control, please see the code snippet below: private void Form1_Load(object sender, EventArgs e) { SetDataSource(dataSet1);// A populated DataSet } protected void SetDataSource(DataSet ds) { dataGridView1.DataSource = ds; ToolStripCon...

Which approach to take with this multithreading problem?

Short question: I would like to spawn a single background thread that would process work items submitted to a queue (like a threadpool with one thread). Some of the work items are capable of reporting progress, some are not. Which one of the .NET's myriad of multithreading approaches should I use? Long explanation (to avoid asking ab...

sorting rows in databound datagridview

Greetings. I have a DataGridGiew, bound to a object datasource - List<SomeType>. I want to sort it by string representations of fields values (ignoring real types) with grid header clicks. I have many grids, that are bound to many lists of different object types. How can i do this as fast as possible? Thanks in advance p.s. framework 2...

How to add column to data-bound control in Windows Forms

Our app has a form that uses a BindingSource with a DataGridView. I've been tasked with adding a column. I don't know where to begin. (In my own programming, I avoid black boxes that I don't understand.) ...

VB.Net WinForms Form OnPaint() Transparency Refresh

Hi All, Long story short, I'm trying to write some toast-style popup notifications (similar to Growl) which should appear next to the system tray and stack as appropriate. I can handle the instantiation/location/etc... but I want to add a capability for non-rectangular toasts. I'd also like to have Alpha transparency so a semi-transpar...