winforms

User Controls in Windows Forms - Anything similar to ASP.NET User Controls?

Hi all, In ASP.NET you have something called "User Controls", which allow you to design a custom control which can be reused in the website. I am now starting developing a Windows application in .NET 2.0 and (surprisingly) I cannot find a similar functionality. What I would like to do is: - Create a new user control in the designer;...

Tab control + DataGridView in WinForms

I have multiple results sets coming back from a server request against a datasource. I want to organise these with a WinForms tabPage for each result set, on a single tabControl. I am displaying the data in a DataGridView, but want to avoid having a DataGridView instance on each tabPage - I'd rather intercept the "switching to new tab ...

How to add WebService to C# WinForm ?

Hi How I can add Webservice to WinForm ? I do not have this Option, why ? thank's in advance ...

Progress Bar in WinForms

Hi all, i need to insert a progress bar between 2 forms ,i have a Main Form when i click a button to open a window i need wait before to load the last one window ('cos there are many picture to download on the last one Form) and i decide to use a Progress Bar to show the time remaining to open the Window requested. Now i don't know how i...

(.NET/C#/winforms) Artifacting when drawing on a Form with Graphics

My objective is to move visual elements drawn using methods of a Graphics object across a Form with no flicker or artifacting (in .NET 3.5). I can successfully achieve flickerless movement by either using automatic double buffering (setting the Form's DoubleBuffered property to true) or implementing a back-buffer myself. I am however s...

XamlWriter fails to serialize objects in WinForms app

Apparently XamlWriter doesn't works correctly in a WinForms application. XamlWriter uses MarkupWriter.GetMarkupObjectFor(object obj). I suppose that there's a problem to determine the full list of properties to serialize. var ar = new AssemblyReference(AppDomain.CurrentDomain.GetAssemblies().First()); var str = XamlWriter.Save(ar); Ru...

Winforms login application samples?

Hey Everyone, I will be working on a Time Management application very soon using Winforms and Access and was looking for some good resources on how to create a simple password protected application. I came from asp.net but have VERY little experience with Winforms. Are there and end to end tutorials for something like this? Thanks ever...

What am I doing wrong with my custom "HorizontalRule" control?

I've written the following (very simple) control for use in an application (comments removed for brevity): public partial class HorizontalRule : Control { public HorizontalRule() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var g = e.Graphic...

How would one get a DataGridViewCheckBoxColumn to show DataRelation status?

Say I have a DataGridView (named dataGridView) that is displaying a Strongly Typed DataTable (named ChildDataTable). dataGridView has a DataGridViewCheckBoxColumn (named parentIDColumn) that is bound to a Field Property ParentID on each ChildDataRow in ChildDataTable. ParentID is a foreign key that relates ChildDataTable to another Dat...

C# UserControl.VerticalScroll.Value not being set

I've got a chunk of C# code that is supposed to set VerticalScroll.Value within a class that inherits from UserControl. It gets called when any child object of the class changes sizes. The class has its AutoScroll property set to true. public void ScrollTo(int top) { if (top >= this.VerticalScroll.Minimum && top <= thi...

Linq to Entities Vs. Table Adapters (.Net Windows Forms)

I'm starting on a small windows forms project that makes extensive use of editable grids. I want to use Linq to Entities, but while it's trivial to bind a grid to the Linq query it's read-only. I couldn't figure out a good way to have an editable grid that auto-updates the database. (I hacked a work-around where I copy the data into a...

WinForms open popup usercontrol as menuitem menu dropdown?

Been searching everywhere and can't find a way to do this. I have a menubar across the top of my winforms program. Now it just pops up a normal menuitem menu. I would like to disable that menu and popup a nice looking usercontrol that looks like its the dropdown for that menu item but includes much more customization. A good example wou...

Why are Font Handles not being disposed?

I am using GDIView to try to track down the source of a few lingering GDI handles, and the source seems to be Fonts used in a menu on the form. The only way I've found to make sure the font handles are GCed is to explicitly set them to null like this: tsmiTextLocation.Font = null; tsmiLocationSelection.Font = null; This doesn't seem ...

Winforms to WPF conversion: BeginInvoke to what?

Hi all, Here's my old code from WinForms: private void ValueChanged(double inValue1, double inValue2) { //only manual mode for this driver, so that's easy. if (ValueLabel.InvokeRequired) { ValueLabel.Invoke(new MethodInvoker(delegate { ValueLabel.Text = (inValue1* inValue2/ 1000).ToString...

How can I run another application within a panel of my C# program?

I've been reading lots on how to trigger an application from inside a C# program (Process.Start()), but I haven t been able to find any information on how to have this new application run within a panel of my C# program. For example, I'd like a button click to open a notepad.exe WITHIN my application, not externally. Thanks. ...

Dashed rectangles appear solid when expanding Winform window.

I'm experiencing an issue with GDI+ while custom painting dashed rectangles. The vertical portion of dashed rectangles appear as solid, continuous lines when the window size is increased or when scrolling up/down. Moving the mouse faster results in fewer and fewer solid sections. Curiously the horizontal lines do not exhibit this be...

When developing for a tablet PC, how do I determine if the user clicked a mouse or a pen?

How do I check if the user clicked with a mouse or with a pen stylus on a C# control. For eg. If the user clicks a text box with a pen button then I want an input panel to pop up but if he clicks with a mouse then it shouldn't. So how do I check whether he was using a mouse or a pen? Edit: Using Windows Forms not WPF ...

Forwarding a Keystroke to another Control in WinForms

I am receiving a keystroke in a Form object's OnKeyDown. When some conditions are met (such as the keystroke is a printable character and not a hotkey) I want to forward the key to a text control on the form and set focus to the text control so the user can continue typing. I am able to decode the character typed using MapVirtualKey but ...

C#: How to add a line to a memo?

Hello, I have a RichBox(memo) that I'd like to add lines to. Currently,I use this RichBox1.text += "the line I'd like to add" + "\n"; Isn't there something like the method in Delphi below? Memo.Lines.add('The line I''d like to add'); ...

How do I reset a .NET Windows Forms TextBox BackColor property?

The default behavior of property BackColor of a TextBox is as follows: when enabled, it is White (SystemColors.Window), when disabled it is Gray (not sure what SystemColor this is). If I change the BackColor property, the same color is used for both Enabled and Disabled. How do I reset the BackColor property (after it has been changed ...