winforms

Autoscale Font in a TextBox Control so that its as big as possible and still fits in text area bounds

I need a TextBox or some type of Multi-Line Label control which will automatically adjust the font-size to make it as large as possible and yet have the entire message fit inside the bounds of the text area. I wanted to see if anyone had implemented a user control like this before developing my own. Example application: have a TextBox ...

Save ListBox_SelectedItem to file.txt.

HI all, i wish save in a file.txt the chronology of the song played by my music Player . I tried this code snippet but doesn't work : StreamWriter sw = new StreamWriter(@"c:\Media PlayList\List.txt"); private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { wmp.URL = Convert.ToString(listBox1.Selecte...

How to download an image from web showing the progress of the download in c# using winforms?

I download an image from an URL asynchronously using WebRequest this way: public void Download(string url) { byte[] buffer = new byte[0x1000]; WebRequest request = HttpWebRequest.Create(url); request.Method = "GET"; request.ContentType = "image/gif"; request.BeginGetResponse(result => { WebRequest webRequest = result...

Winforms UserControl shows rectangles with Inverted Colors

In a Winforms application (C#2, FX2.0, VC2008) I am using a Panel derived Control to display custom controls. The controls are arranged vertically and there are usually more than fit in the visible area of the panel. I have drawn a litte sketch of it: Sometimes (usually after scrolling inside the panel) rectangular areas appear to ha...

What is the most "lightweight" winforms control?

(This is probably a dumb question AND a WTF combined, but here goes nothing) I want to 'draw' lines or areas in my interface - typically separators inside a TableLayoutPanel. Currently what I do is just dump a Panel in the row and set it to Dock=Fill and give it the background required colour. Just before doing the same thing, I wonder...

Should we not use the System.Web.Caching.Cache class in a WinForms app?

I've seen several articles/blog posts that advocate the use of the System.Web.Caching.Cache in applications that are not for the Web, however, the MSDN documentation quite clearly states that The Cache class is not intended for use outside of ASP.NET applications. It was designed and tested for use in ASP.NET to provide caching for ...

How can I make a 'Partially' modal dialog?

Is there a way to start off showing a dialog modally, but then instead of hiding it, to keep it visible while changing it to a non-modal dialog? I want to show a dialog, blocking the method that shows the dialog. Then when the user clicks the 'Finish' button on the dialog I want: The dialog to remain visible. Control to return to the...

Windows Forms - ErrorProvider + DataGridView

How can I hook in the ErrorProvider with individual cells on the DataGridView control? ...

Visual Studio Designer is always trying to change my control

I have a somewhat complex UserControl, and Visual Studio 2008 is giving me a rather harmless annoyance when working with it. Every single time I open the control with the Designer, it decides to immediately change some of the harmless values set by the designer - namely the initialization of Size properties. If I save those changes, cl...

Adjusting the number of X intervals in Microsoft Chart Controls

I'm using the Microsoft Chart Controls and databinds it like this: chart1.Series["Default"].Points.DataBindXY(events.Dates, events.Values); //where // events.Dates is IList<DateTime> // events.Values is Double I'm having some issues getting the chart/chartarea to display a reasonable amount of intervals though. It works fine on Auto...

Animated GIF in ImageList / TabPage

I'd like to show an animated GIF as the tab image on a TabPage. If I add my image to an ImageList and use the TabPage.ImageIndex property, it only shows the first frame (and doesn't animate): ImageList imageList = new ImageList(); imageList.Images.Add(Properties.Resources.my_animated_gif); tabControl.ImageList = imageList; tabPage.Ima...

C# AutoComplete

I am trying to add an autocomplete feature to a textbox, the results are coming from a database. They come in the format of [001] Last, First Middle Currently you must type [001]... to get the entries to show. So the problem is that I want it to complete even if I type the firstname first. So if an entry was [001] Smith, John D...

What are the pros and cons of these client options in C#? winforms, WPF, Jquery, ASP.NET AJAX, and Silverlight

just wanted to clarify the options for client presentation : 1) winforms - for windows client - older technology 2) wpf - for windows client - newer technology, uses xaml 3) jquery - for web client - uses javascript 4) asp.net ajax - for web client - older technology 5) silverlight - for web client - new...

How can I prevent the keydown event of a form in C# from firing more than once?

According to the official documentation, the KeyDown event on a Windows Forms control occurs only once, but it is easy to demonstrate that the event fires continually aslong as a key is held down: private void textBox1_KeyDown(object sender, KeyEventArgs e) { label1.Text = string.Format("{0}", globalCounter++); } H...

What is the difference between GTK# and Windows Forms?

Hello, What is the difference between GTK# and windows forms? Are they totally different? Thanks ...

StringConverter with StandardValuesSupported and Autocompletion

I want to develop a StringConverter with standard values, which after attaching it to a PropertyGrid will act like comboBox with autocompletion. The example below will give me a comboBox, but without the autocompletion - user have to expand it and choose manually one of the items. Is there a way to allow user to type the beginning of one...

Search datagridview on user keypress

Hi, I'm trying to select the first row where the cell value starts with the same keychar the user pressed. That's the part that is giving me trouble. Here's how I'm handling the event (updated with working solution): private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e) { if (Char.IsLetter(e.KeyChar)) { ...

Calling a Method of a Windows Form Without an Active Form Instance

I'm developing a windows application in C# using VS2005. Consider i need to call a non static method(Method1) which is in a class(Class1) from another class(Class2). In order to call the method, i need to create object for that class. But my class 'Class1' has more than 1000 variables. So every time i create object for 'Class1', all the...

Form showing as a class in Solution Explorer

I have a form in my project that is showing up as a class in Solution Explorer. This is causing a problem since I can't get to the designer. Any ideas on how to fix this? ...

Catching errors in an ASP.NET webpage from winforms

I am writing a WinForms app which will execute some web UI tests written in a web testing framework. Is there a way I can get the error on the page being tested (I specify the page through a method parameter) without screenscraping the page? For example, if it throws: A potentially dangerous Request.QueryString value was detected from ...