winforms

A beginners Entity Framework query to populate a WinForms ListView.

I've just started learning how to use the Entity Framework to write a very simple C# network monitoring program - this is a learning exercise to try and "drive home" what I've only read about to date. I'm also new to C# and LINQ (just to complicate things further.) I believe I have the data model suitably normalised but I may be wrong. ...

C#: Accessing form members from another class

Hello, The point is to notify the user using the memo when a packet is received/sent in a TCP Client. The old code was extra dumb,I used a Timer that used to add text in the memo since the Timer has access to the form members,lol. The old code: //Memo.Text += txt + "\n"; I played with it today,this is what I've done In Form1's clas...

Accessing Class members with Invoke from a different thread in C#

Note: Part of a series: C#: Accessing form members from another class and How to access form objects from another cs file in C#. Hello, The Idea is to notify the user using the memo when a packet is received/sent in a TCP Client. After couple of fixes,the most suitable solution seemed to be this one public string TextValue ...

How do I tell CodeDomComponentSerializationService not to copy certain property values?

I have a custom WinForms designer, and I've just added functionality to create duplicate components using drag & drop (with the ctrl key held down) by inheriting from CodeDomDesignerLoader. Unfortunately, this works a little too well: the new components get all of the same property values as their originals, and I need some of those to b...

How can I use the Windows look'n'feel for a system tray context menu?

I'm working with a NotifyIcon and ContextMenuStrip, I don't want to use the default menu look and feel which is shipped out of the box with this control which is different to Windows (Vista in my case) by using contextMenu.RenderMode = ToolStripRenderMode.ManagerRenderMode or contextMenu.RenderMode = ToolStripRenderMode.Professional: ...

Question on exporting to Excel from winforms using C#

Hello. I am creating a small winforms application for distribution to a few people. I would like the users to be able to export the contents of a DataGridView to a file that Excel can read. I would like the file to be a excel file and not csv or xml. In the past when I have created an "export to excel" function I have always had to incl...

winform mdi catch child form focus c#

I would like to be able to catch a child window focus event, in an mdi form. If i loose focus to the entire mdi application, then click on a child, it works, but if I had two child forms open, I cannot catch the focus event when clicking between them. I am using Dotnet Framework 2.0, and I need the code solution that will run fine on a...

Problem with Z-Order involving TopMost and Invoke

I am showing Dialogs with Form.ShowDialog(). Forms are set to TopMost. Some image processing calculations are performed asynchronly in the background. Their results are rendered in the main form by Invoke. So far so good. Strange thing is that every now and then the modal dialog is moved behind the main form. I guess that happens when th...

How to determine the size of a string given a font.

I have a small form that displays some progress information. Very rarely I have to show a rather long message and I want to be able to resize this form when needed so that this message fits in the form. So how do I find out how wide string S will be rendered in font F? ...

System.Web.dll references System.Windows.Forms?

I heard from a friend that asp.net relies on/uses a Windows forms class. I tried to figure out which class that might be. The only class I found was System.Web.UI.WebControls.FontInfo with the property public string[] Names that has an Attribute Editor("System.Windows.Forms.Design.StringArrayEditor--snip") Is there a reference to the...

WinForms: variable number of dynamic TextBox controls

I have to create variable number of Labels and next to them TextBox controls - arranging the whole thing into a column, each line a Label and a TextBox. If the my Main window is smaller than the total height of all the TextBox controls, somehow I need a scrollbar which can scroll the list of TextBoxes. Pressing the enter key would have t...

System.Windows.Forms in asp.net 3.5

I'm trying to implement a website screen shot class as described here http://www.plentyofcode.com/2007/09/website-screenshot-capture-with-aspnet.html The class imports the following methods Imports System Imports System.Drawing Imports System.Drawing.Imaging Imports System.Windows.Forms Imports System.Diagnostics Namespace GetSiteThum...

Differences setting content in Forms.WebBrowser control via DocumentText vs. Url

If I generate some HTML and have it in a string and then say: myWebBrowser.DocumentText = string; It seems to work just fine, except none of the images load (I get the broken image graphic). If, however, I write the string to a file and then say: myWebBrowser.Url = new Uri("file://myfile.html"); Everything works just fine. My q...

How to prevent the beep sound caused by alt key pressed in a WinForms TextBox?

I'm creating a routine that allows the user to replicate keyboard shortcuts into a textbox for 'custom keyboard shortcuts' customization, but every time the alt key is pressed with another letter, it produces another sound. I'm capturing the keys in the textbox_keydown event to parse the modifiers + other keys into a readable Shift + A...

C#: What is the ideal method of adding a splash screen to a project?

I'm going to input a splash screen to an application I'm currently working on that only consists of one form which we will call frmMain for now. I want to implement a splash screen (frmSplash) but need advice as to what would be the best way to implement it. The purpose of the splash screen will be to load necessary settings into textbox...

Generify-ing The .NET Background Worker

We're working on a Windows App that periodically has to launch operations which may take some time. We've gotten into a pattern of having these operations run on a BackgroundWorker, and writing up a quick WinForm for each operation, where you pass in to the form the necessary parameters, the form wires up the BackgroundWorker and makes ...

How do I set a ScrollBar's value when it grows dynamically?

I'll start by what I'm trying to have happen: I have data loaded in a range, where, say, scrolling all the way to the left puts me on April 1, and scrolling all the way to the right puts me on June 1. The user positions the scrollbar on April 1st, and clicks the left arrow on the scrollbar. Now the scrollbar is positioned at March 31,...

Do .NET GUI components support HTML (like Java swing does)?

HTML can be used in Java swing GUI components, like JTextBox, JButton, ... etc. Is there an equivalent to that in .NET (C#) WinForms? or at least some simple way of making a single word bold inside a textbox without using another GUI component? ...

Setting background of WinForm ListBox

Does anyone know a method to insert a image in background into a ListBox in WinForms C#? Thanks for your attention. Nice Regards ...

WindowsMobile: Application Exits after handling Exception from DialogForm

I have the following simple scenario: A DialogForm with a Button, the Button_click throws an exception. A MainForm with a button and a Label, in the click I show a new instance of the DialogForm inside a Catch block. If I run this setup in regular WinForms, I can catch the Exception as expected. If I run this in WinMobile (I've test...