winforms

Binding to a Nullable<DateTime> control property

We have a custom control that has a "Value" property of type System.Nullable (aka System.DateTime?). We have an object with a "Received" property of the same type. When we try to bind the control to the object, the following InvalidCastException is thrown: Invalid cast from 'System.DateTime' to 'System.Nullable`1[[System.DateTime, msc...

How to break a context menu into more than one column in Winforms?

I have a ContextMenuStip that contains a dynamically generated list of ToolStripMenuItem objects. The problem is that when there are too many of them to fit onto the screen, tiny scroll buttons appear at the top and at the bottom of the list, and scrolling through the list is a bit tedious. How can I make the menu to automatically break...

Compile ASPX in WinForms App

I'm writing a WinForms application that sends email messages (like a mail merge). I'd like to use ASP.Net's rendering engine to render the HTML bodies of the messages. What's the simplest way to get the rendered output of a single ASPX page without the entire ASP.Net runtime? To make things harder, I'd prefer to compile the ASPX at ru...

Implement WinForms using WPF?

This question is a result of a lunch-time conversation with a co-worker...I've read questions like WPF vs. Winforms...and I personally think that long term WPF is the way to go. The problem/question is what to do in the meantime. Yes, WPF certainly has its advantages; not being built on GDI/USER is one of them. But at this point in ti...

Search a list box while typing in a text box in Winforms C#

I have a list-box where items are loaded from database , when user types anything in text-box, list-box should search the starting characters entered and display it in text-box.? For example : As soon as User types "A" in text-box ,then all the records starting from "A" should be displayed in List-box. When user selects the record and...

Slowdown identified: ReaderWriterLock(-1). May I use different locks?

Hi, after hours of tracking mysterious one or two seconds long lasting "freeze" I finally found out that its ReaderWriterLock(-1). It is server app and the lock here is held for writing to client collection. Im not familiar with locking so I would like to ask if there is not any better/faster way? How about using lock object to lock add/...

csharp winform modal window, able to click on main window

language c#, winform how do i create a modal window or such a thing that when it still showing i would still be able to click or interact with the main window.. thanks. put some code please or links.. ...

Which control to use for quick textinput?

Hello, I need a quick text input dialog box. (MessageBox with a single Text box in it). Is there any control available or should use a form? I just want user to enter some ID. And in other occasion I want 2 texboxes for Username & Password. ...

Why is the winforms designer ignoring attributes on overriden properties ?

I've got a user control defined like this : public partial class FooControl : UserControl { private System.Windows.Forms.GroupBox groupBox1; ... I wanted to make groupBox1.Text accessible directly from the designer so I went for the obvious solution and created the following property in my FooControl : [Catego...

Getting the collection of controls (including buttons) on a Winforms form

Hi, I have a winforms app and the main (and only) form has several buttons. When the user clicks a button, I want all other buttons to be disabled. I know I could do this the long way by setting "Enabled" to false on all buttons but the one which has been clicked in the clicked event handler of that button, but this is a long and tedio...

Move items from one listbox to another

I'd like to move items from one list view to another. adding them to the second one works but the moved entries don't get removed at all. private void MoveSelItems(ListBox from, ListBox to) { for (int i = 0; i < from.SelectedItems.Count; i++) { to.Items.Add(from.SelectedItems[i].ToString()); } ...

Miss behaviour on .Net Controls DataSource property..

I have a WinForm Application with a grid that contains a ComboBox on each row. All are binded to the same collection ( The collection might change behind that's why I don't want to have different collections for each Combo, also memory cost). The issue is that when I select some object in one combo it changes the selected object on every...

How can I start showing an interlaced PNG before all data has been received?

I have a slow connection that I need to send a PNG image over (as a byte stream) and have the image be displayed immediately. I have a C# WinForms app accepting the byte[], loading it into a memory stream, and creating an System.Drawing.Image/Bitmap object from it. What I would like to do is send a super low resolution image down, and t...

Databinding NOT working

Hi all, problem with binding... I have a "Detail" form with.. say 5 controls with buttons for add/edit/save/cancel/exit. I have a second "Find" form used to find a record from a back-end datasource. I get the selected record's ID and call the "Detail" form. The "Detail" form dynamically does the binding via textboxSample.DataBi...

How can I cause anchored child controls to resize themselves?

C#. I'm filling a panel with controls such that a scrollbar comes up. When the scrollbar shows up, I would like the controls (anchored top|left|right) to resize so they aren't covered by the scrollbar. If I make the form bigger and then smaller again, they resize properly, but I don't know how to make them do this sizing when the scrollb...

Global variables v Settings in C#

I have read in various places that having variables with global scope, i.e. a public static class with static members, is considered going against the philosophy of OO, and is not good design. (For example, I have seen comments along the lines of: "If you are using a global, you are not doing it right." Or words to that effect.) But, if...

DataGridView Exception thrown during InitializeComponent

This is only occurring on a user's machine, not mine. I cannot recreate this issue. Since this is occurring inside the DataGridView's internal code, I'm not quite sure how to proceed. Any ideas? ************** Exception Text ************** System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the...

problem with two controls having the same datasource

I am building a winforms application, i have two comboboxes which have the same datasource, the datasource is a DataTable. Now, when I select a value in one comboBox, the value of another comboBox is changed too. Is there a way make it change without affecting the other? ...

How to build efficient KPI list for WinForms

I need to build a Windows control that displays KPI indicators. Something similar to the one displayed at the following picture. There are also the following requirements: List needs to refresh from a background thread every ~15 seconds It needs to handle 100+ indicators My initial idea was to use FlowLayoutPanel with a combinatio...

Up, Down, Left and Right arrow keys do not trigger KeyDown event

I am building an application where all the key input must be handled by the windows itself. I set tabstop to false for each control witch could grab the focus except a panel (but I don't know if it has effect). I set KeyPreview to true and I am handling the KeyDown event on this form. My problem is that sometimes the arrow key aren't ...