winforms

How to change the font color of a disabled TextBox?

Hi, Does anyone know which property sets the text color for disabled control? I have to display some text in disabled TextBox and I want to set its color to black. Thanks! ...

C#: Is there a shortcut to detect if mouse is still hovering on top of Label on MouseHover event?

C#: Is there a shortcut to detect if mouse is still hovering on top of Label on MouseHover event? Just curious if there's a bool to check, if not to get mathematical then :(. ...

First "programs" in a non-web environment

I'm starting to re-skill myself in Desktop applications. I've been doing Web applications for a few years now. I've got come decent C# books that I am going through, but they are more like language references. What I would like is a list/site/book with practical exercises, preferably graded in terms of difficulty. They don't necessaril...

How would I make a control that flashes/fades on a mouse click? (Windows)

When a user clicks in certain places in my control, I want to change the color of some rows and columns in my grid, then fade it back to the normal color, within say 500ms or so. I haven't decided whether to use Winforms or WPF yet, so advice in either of those technologies would work. Thank you. Edit: I understand I could do this by ...

how to run a winform from console application?

How do I create, execute and control a winform from within a console application? ...

.NET set image display size

I am using some custom controls one of which is a tooltip controller that can display images, so I am using th ebelow code to instantiate it: Image newImage = Image.FromFile(imagePath); e.ToolTipImage = newImage; obviously could inline it but just testing at the moment. The trouble is the image is sometimes the wrong size, is there a ...

Keep window on top and steal focus in WinForms

I realize that this would be COMPLETELY bad practice in normal situations, but this is just for a test app that needs to be taking input from a bar code scanner (emulating a keyboard). The problem is that I need to start up some scripts while scanning, so I need to window to regain focus directly after I click the script to run it. I'v...

Tag cloud control for WinForms .NET 2.0+

How would you render a tag cloud within a .NET 2.0+ WinForm application? One solution that I am thinking of would be using the WebBrowser control and generating to some ad-hoc HTML, but that seems to be a pretty heavy solution. Am I missing something more simple? ...

Is there a .NET Framework method for converting file URIs to paths with drive letters?

I was looking for something like Server.MapPath in the ASP.NET realm to convert the output of Assembly.GetExecutingAssembly().CodeBase into a file path with drive letter. The following code works for the test cases I've tried: private static string ConvertUriToPath(string fileName) { fileName = fileName.Replace("file:///", ""); ...

How do you check for ajax updates using a WebBrowser control in .net 2.0?

I have a web page that is being displaying in a winform app using the WebBrowser Control. I need to perform an event when the HTML in the web page changes; however, I cannot find an event that is triggered for situations when the pages is updated through Ajax. The DocumentComplete, FileDownloaded, and ProgressChanged events are not alway...

How to detect when the mouse leaves the form?

I have a form with a lot of controls on it. How can I detect when the mouse leaves the form? I've tried wiring up a MouseLeave event for every single control and the form, but that does not work because those events fire all the time as the mouse passes over controls. Is there a way that actually works.? ...

Bring Windows Mobile 6 forms into the front

I have problems with bringing a windows mobile 6 form to the front. I tried things like this already Form1 testForm = new Form1(); testForm.Show(); testForm.BringToFront(); testForm.Focus(); But it's always behind the form that includes that code. The only things that have worked for me are testForm.TopMost = true; or Hide(); the o...

Order of controls in a form's Control property in C#

I am having a peculiar problem with the order in which FlowLayoutPanels are added in to the form's controls property. This is what I tried, I added 7 FlowLayoutPanels in to a C# window application from left to right in vertical strips. Then I tagged the flow layouts as 1, 2, 3, ... 7 again from left to right. Now in the load handler of ...

Window handle debugging in Winforms

I have a user that keeps getting this error. Is there a tool that does window handle counting that i can use to figure out why he keeps getting this error. System.ComponentModel.Win32Exception: Error creating window handle. at System.Windows.Forms.NativeWindow.CreateHandle(CreateParams cp) at System.Windows.Forms.Control.CreateHa...

C# beginner help, How do I pass a value from a child back to the parent form?

How do I pass a value from a child back to the parent form? I have a string that I would like to pass back to the parent. I launched the child using: FormOptions formOptions = new FormOptions(); formOptions.ShowDialog(); Many thanks ...

Make user control display outside of form boundry

I've decided to reimplement the datetime picker, as a standard datetime picker isn't nullable. The user wants to start with a blank field and type (not select) the date. I've created a user control to do just that, but if the user control is near the edge of the form, it will be cut off on the form boundry. The standard datetime picker ...

Is it OK to overload ShowDialog() so that a child form returns information as an out parameter?

In an earlier question about how to return a string from a dialog window, yapiskan suggested overloading the child form's ShowDialog() method to include an out parameter. My question is whether or not this is a good approach in C#. Here is some example code, based on yapiskan's suggestion. In the child form (in this example, it's a fo...

Read-only DataGridView and IEditableObject

Good evening I've got a little problem with my DataGridView in a .NET Windows Forms project. The grid is read-only and bound to a sortable BindingList<T> which contains custom business objects. My business object class does implement IEditableObject. Now the BeginEdit and EndEdit methods are called all the time while navigating in the ...

Use a separate scroll bar for a textbox

I am developing a touch screen application that has to display a possibly large amount of text. The problem I am having is that the default scroll bar attached to text boxes is just too small to be practically used in a touch screen application. I have tried adding a separate scroll bar control and using it to control the scrolling of th...

Drag and drop from Windows File Explorer onto a Windows Form is not working

I'm having an issue dragging a file from Windows Explorer on to a Windows Forms application. It works fine when I drag text, but for some reason it is not recognizing the file. Here is my test code: namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { Initialize...