winforms

WinForm Text Control that displays current character/character limit

I need a way to display, like you see in some web apps, the current characters/character limit for a Text Control(i.e. 3/500). I usually see this as a label residing directly above or below the Text Control. How is this 'normally' accomplished? Should I override my Text Control somehow? Do I just manually add labels by every Text Con...

Assigning custom objects to array with a for loop?

Given this example: // Create an arary of car objects. car[] arrayOfCars= new car[] { new car("Ford",1992), new car("Fiat",1988), new car("Buick",1932), new car("Ford",1932), new car("Dodge",1999), new car("Honda",1977) }; I tried something like this: for (int i = ...

Can I get the item type from a BindingSource?

I would like to get the Type of item that a BindingSource is hooked up to or configured for. The BindingSource.DataSource property can be set to an object, list, or type. If it is a Type, it obviously does not have a bound item yet, but I would still like to get the Type. For a List, I need the item Type, not the list type. I current...

C# async callback on disposed form

Quick question: One of my forms in my winform app (c#) makes an async call to a WCF service to get some data. If the form happens to close before the callback happens, it crashes with an error about accessing a disposed object. What's the correct way to check/handle this situation? The error happens on the Invoke call to the method to ...

Host a Silverlight application in Winforms application

I have a need to host a Silverlight application as a module in an existing WinForms application. My plan is to host the web page that hosts the Silverlight app in a web browser control in the WinForms application. The part I have not been able to figure out is how to communicate from the Silverlight application back to the Winforms appl...

Binding to a WPF hosted control's DependencyProperty in WinForms

I have a WinForms app with some elements that are hosted WPF user controls (using ElementHost). I want to be able to bind my WinForm's control property (Button.Enabled) to a custom DependencyProperty of the hosted WPF user control (SearchResults.IsAccountSelected). Is it possible to bind a System.Windows.Forms.Binding to a property man...

How can I force a winforms app to use the fonts/fontsizes I specify on every machine?

How can I force a winforms app to use the fonts/fontsizes I specify on every machine? I have a c# app where the font seem to change in size on a different machine, and it's not a resolution thig. This is on windows 7 with a c# app. Is there a way to force the font size I want or do the user os fonts always overrule? ...

What's the best way to handle the same shortcut in WPF and WinForms controls?

I have a WPF application with the following KeyBinding on its main window: <KeyBinding Command="Commands:EditCommands.Undo" Gesture="CTRL+Z" /> <KeyBinding Command="Commands:EditCommands.Redo" Gesture="CTRL+Y" /> This makes the command respond to the shortcut fine. However, in all the places where I have embedded WinForms text boxes o...

How to assign a numbering scheme to TreeNodes based on position

I have a TreeView control in a Windows Forms application that is displaying my own subclass of TreeNode. I need to display a number along with each node's text indicating its position in the tree, like 1 for the root, 1.1 for its first child, 1.2 for its second child, etc. I'm using C# with .NET 2.0 The best that I can come up with is, ...

Why do my horizontal toolstrips keep stacking verticaly?

I'm using a ToolStripContainer that contains three ToolStrips. At design time I move the ToolStrips to the positions I want them in, which is in a horizontal row across the top of the form like this: I then close and save the Form. However, if I open the form up again the ToolStrips end up stacked up on the left side of the ToolStripC...

How to raise a validation event from a key press

Hi, I want to raise the: private void txtbox_startdate_Validating(object sender, System.ComponentModel.CancelEventArgs e) {} Function from a key leave event. The leave event looks like: private void txtbox_startdate_Leave(object sender, EventArgs e) {} The trouble is of course if I try and call it in this manner: txtbox_...

When is it worth using a BindingSource?

I think I understand well enough what the BindingSource class does - i.e. provide a layer of indirection between a data source and a UI control. It implements the IBindingList interface and therefore also provides support for sorting. And I've used it frequently enough, without too many problems. But I'm wondering if I use it more often ...

How to make Form Transperent in windows c# ?

How to make Form Transperent in windows c# ? I have a GridView in my form, which should be visible. ...

Store the cache data locally

Hello, I develops a C# Winform application, it is a client and connect to web service to get data. The data returned by webservice is a DataTable. Client will display it on a DataGridView. My problem is that: Client will take more time to get all data from server (web service is not local with client). So I must to use a thread to get d...

What is the Browser version of a WebBrowser control in Windows Forms

I'm building a Windows Forms application which makes use of the WebBrowser control. Can anyone tell me what rendering engine the control uses? Is it fixed based on the version of the .NET framework I'm developing against or is it based on the version of IE installed on the client's machine? Does the client even need IE? In other word...

To set a background image in .Net form

i want to set an image to my .net form background using BackgroundImage propery but its not working so plz help me with it as soon...thnx in advance ...

DataGridView population+modificaion by SQL Server DB View

I searched StackOverFlow.com for my issue, but could not find any similar/related solution. I have few tables in SQL Server 2005, and have to make use of those tables in my Winform/C# application which is supposed to be an Admin Application where the Administrator will:- 1.Add/Edit users 2.Assign Roles 3.Assign Privileges 4.Zone As...

PaintEventHandler logical issue

I am creating a few pictureboxes dynamically, then assigning the following: // class variable public String PaintLabel; // private void Form2_Load(object sender, EventArgs e) //begin loop this.PaintLabel = serialno; Shapes[i].Paint += new PaintEventHandler(ctl_Paint); // end loop // my event override private void ctl_Paint(object sen...

What's wrong with my cross-thread call in Windows Forms?

Hi, I encounter a problem with a Windows Forms application. A form must be displayed from another thread. So in the form class, I have the following code: private delegate void DisplayDialogCallback(); public void DisplayDialog() { if (this.InvokeRequired) { this.Invoke(new DisplayDialogCallback(DisplayDialog)); }...

How to draw a single point with .Net?

Hello, this should be pretty simple but I don't get it. How can I draw a single point in .Net? If I use g.DrawLine(Black,0,0,0,0) nothing is drawn and if I use g.DrawLine(Black,0,0,1,0) a line with 2 dots is used. The same happens with g.DrawRectangle. This has me intrigued. Thanks in advance. EDIT: A box of 1x1 is a box of 4 pixels a...