winforms

Sharing a variable between two winforms

I have a winforms application. I have a textbox on one form (call F1) and when a button is clicked on this form (call F2), it launches another form. On F2, I want to set a string via a textbox (and save it to a variable in the class), and then when I close this form, the string will appear in a label in F1. So I am basically sharing v...

How to call url with basic authentication inside application

I need to create an application (ASP.NET or WinForms or Windows Service, not sure) that needs to make a call to a url including username and password for basic authentication and have the url return a csv file. I then need to use the csv file in the application. I don't know how to do this. How do I call the url in my app. There can ...

How to focus a certain tabpage when it rightclicked?

How to select or focus a certain tabpage when it right clicked? ...

Sort TreeView by Key

How can I sort a WinForms TreeView by using the nodes' keys, rather than by their names? ...

Xna - get window location?

I'm trying to rig an XNA WinForms system so I can have a game editor, and I need to use the mouse for it. Since the XNA Mouse input class reports mouse position based off of the window's location, I need to place the form I have in the same spot. How can i get the location of the window that my XNA game uses? ...

Ninject property injection returns null

I'm sure I'm doing something stupid but this is what we're here for! I've got a WinForms app with the following code: static void Main() { IKernel kernel = new StandardKernel(new MyModule()); TestInterface test = kernel.Get<TestInterface>(); } For the Module.Load() event: Bind<TestClass>().ToSelf().InSingletonScope(); Bind<T...

How to change the text of Label from another Form?

It is a cross threaded operation in windows application done in c#, How can i change it ? ...

MSIEs WebBrowser control hosted in winforms app runs in compatibility mode

I'm hosting MSIE in a winforms form. Unfortunately it insists on running in compatibility mode regardless of if I give it a page that runs in IE8 mode in stand-alone IE. The effect of that is that some content that renders correctly in stand-alone MSIE gets completely mis-aligned and messed up in the hosted control. Besides document typ...

How do I debug Windows Forms Designer crashing?

I have a windows forms project. It has a main form derived from System::Windows::Forms::Form which I can open in designer without any problems. If I try and close designer though, it kills Visual Studio (v2008 with SP1). The form includes a tab control which has pages with various System::Windows::Forms::UserControl derived forms. So I'...

Domain Maintenance Controls/Forms, is there a Pattern?

Hi, I'm working on an application that has a large domain - i.e. Customers, SalesOrder, Suppliers, Products, Stocks etc. - and have discovered that the WinForms data binding is a little too restrictive for what I need. Is there a useful design pattern for setting up the populating of forms and updating of the underlying data? Thanks ...

Redirect cmd output to string in c++ or in memobox?

I have two objects in my form application. First is a listbox where i want to hold the cmd output, and the second is button who have command like, WinExec("cmd /c ipconfig -all", 0);, so question is how to redirect cmd output to the list box. For example, I'd prefer not to save output of ipconfig in file & load from file text to list box...

Code before foreach loop does not execute.

Yay I finally thought of a title! I have a foreach loop that iterates the ListViewItems and does something with each item. But the problem is not that it doesn't do the work in the loop, but it simply does not execute any code that appears before the foreach loop. Below is the full method: private void pNGToolStripMenuItem_Click(o...

WinForm Maximize On Tray Restore?

Hi stack overflow, I have a little problem where if I have a WinForm and maximize it, and send it to the system tray, when I restore it, it isn't the maximum size any longer. I'm trying to set a flag IsMaximized to true if the form is maximized when it is sent to the tray, but when it is being sent to the tray, the form state is mini...

Adding a comboBox to a gridview in WinForms

I am trying to create a gridview with a string column, a checkbox column, and a dropdownlist/combobox column. The first two are finished (all code behind), just need help with the last one. DataTable dt = new DataTable("tblAir"); dt.Columns.Add("Flight Details", typeof(string)); dt.Columns.Add("Prefered Seating"...

Creating Overlay Control in winforms

I am using c# winforms to show an Image. The displaying of the image is done using a user control. Now I want to provide the user to draw lines, put other small images, write text etc over the image on an overlay control. How can I provide this functionality? If I use another user control to show the overlay control with transparent back...

ContextMenuStrip On RightClick, IF Items Are Selected In Listview?

I have a ContextMenuStrip attached to a list view, and it's working great, but what I'm interested in knowing is how I can have it show up only when one or more items are selected in the listview. Thanks! ...

Modify mouse crosshairs code to be on top of form?

On a blank winform code can be added to show lines that intersect (crosshairs) at the mouse pointer. The problem is that the lines don't show (or are partially hidden) by controls on the form (ie listview, splitcontainer, buttons). How would I modify the code below to show on-top (bring to front...) of all the controls present on the...

How to change language at runtime without layout troubles

I have a winforms application that the users must be able to change the language at runtime. To generalize the switch and avoid having to hard code control names I tried the following extension: internal static void SetLanguage(this Form form, CultureInfo lang) { ComponentResourceManager resources = new ComponentResourc...

How do I assign an event handler in winfowms using a custom ShowDialog?

I have a ShowDialog that takes several parameters. Is there a way to also pass it a delegate to handle an event on the parent form? (As opposed to instantiating the dialog, then adding the event, then calling the default ShowDialog) Simplified sample, if I wanted a change on the dialog to reflect instantly on the opening form: public...

Winforms Minimization Techniques

I am trying to make my application "flip" when the minimize button is pushed. By flipped, it should be kinda like a coin when flipped. It "flips" down into the taskbar. I am wondering how effects like this are accomplished in WinForms using C#. Can this be done or does something like this need to be done using DirectX? ...