winforms

WinForms TabOrder tool: Broken or just confusing?

Hi all, I have a form with a bunch of panels, and some panels inside groupboxes. When using the TabOrder tool in Vs2005, the controls outside of containers are given integers (0), the controls inside panels are given decimals (72.0), and the controls within panels within groupboxes are given three-part values (73.73.0). Unfortunately th...

how to convert windows forms browser control's document object to mshtml.IHTMLDocument2

Trying to get this line to work mshtml.IHTMLDocument2 doc2 = webBrowser1.Document as mshtml.IHTMLDocument2; but getting the error message Error 10 Cannot convert type 'System.Windows.Forms.HtmlDocument' to 'mshtml.IHTMLDocument2' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type co...

WinForms ComboBox DropDown and Autocomplete window both appear

I've got a combobox on a winforms app with this code: comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; DataTable t = new DataTable(); t.Columns.Add("ID", typeof(int)); t.Columns.Add("Display", typeof(string)); for (...

C# Prevent ItemChecked event on a ListView from Interering with SubItemClicked?

I am using a in-place editable listview control for a project. The editable listview adds a 'SubItemClicked' event so that each 'cell' can be edited. lstSD2.SubItemClicked += new ListViewEx.SubItemEventHandler(lstSD2_SubItemClicked); I also have the listview checkboxes enabled with a 'ItemChecked' event. The problem is that once t...

Change i18n resources path for .Net Windows application

Hi, We are migrating a .Net windows application to Windows 7. This application can be used in multiple languages, but only English is installed by default. There is a menu item that allows users to download additional languages. This application is using the standard .Net satellite resources folder organization: http://msdn.microsoft.com...

How To Start And Stop A Continuously Running Background Worker Using A Button

Let's say I have a background worker like this: private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { while(true) { //Kill zombies } } How can I make this background worker start and stop using a button on a WinForm? ...

C# Closing a form during a constructor

Is it possible to close a form while the constructor is executing (or simply to stop it showing at this stage)? I have the following code: public partial class MyForm : Form { public MyForm() { if (MyFunc()) { this.Close(); } } } Which errors in Main(), here: ...

Testing complex entities

I've got a C# form, with various controls on it. The form controls an ongoing process, and there are many, many aspects that need to be right for the program to run correctly. Each part can be unit tested (for instance, loading some coefficients, drawing some diagnostics) but I often run into problems that are best described with an exa...

Overriding the combobox events

Is it the wrong way I am doing this: - first I created a class inheriting from Combobox and I am gonna override some events, so something like this: public override void SelectedIndexChanged(object sender, EventArgs e) but it tells me : "There is no suitable method for override" Thanks ...

Order of Form Load , Form Shown and Form Activated Events

What is the difference between Form Load , Form Shown and Form Activated Events ? What is the order in which they are fired ? ...

Cannot change the Label text!

I have created a custom control and added a label property to it so at design time we can pick a Label and assign it to that control. so basically I want that if a label is assigned to that control, its text should change as below and also its text should change to bold font, so here is that code: private Label assignedLabel; public La...

Can I temporarily prevent manual changes to a DataGridView from updating the underlying data source?

I tried to find another question like this one, since it certainly seems like something that may have been asked before; but I couldn't find it. Basically, I've got a DataGridView, which is bound to a BindingList<T>. I understand that in general, data binding is very nice and saves a lot of (our -- developers') time. However, there is a...

When Something Occurs in a BackgroundWorker, Trigger Code on a Different Thread?

I have a background worker that runs and looks for stuff, and when it finds stuff, I want to update my main WinForm. The issue that I'm having is that when I try to update my WinForm from my background worker, I get errors that tell me I can't modify things that were made outside of my background worker (in other words, everything in my...

What is the best way to embed controls in a list/grid

I have a table of about 450 rows that I would like to display in a graphical list for users to view or modify the line items. The users would be selection options from comboboxes and selecting check boxes etc. I have found a listview class that extends the basic listview to allow for embeding objects but it seems kind of slugish when I ...

Snap to grid in millimeters on a panel?

I have a panel. I need to represent it in WYSIWYG. Now, when drawing on it, is possible to draw using millimeters instead of pixels. graphics.PageUnit = GraphicsUnit.Millimeter graphics.DrawRectangle(pen,rect) Is it possible to position the controls(buttons, textboxes) also in millimeters, in order to get a "real" paper image of the...

How to catch exception when loading .NET WinForm app user.config file?

Sometimes in .NET (2.0) WinForm desktop apps which use the default configuration system, the user.config file will become corrupted and can't be loaded anymore (when the configuration system tries to load it, it'll throw a System.Xml.XmlException). Putting aside the question of "why did the file get corrupted in the first place" (maybe ...

ListBox.SelectedIndexChanged - can you determine if it was user intiated?

My question is similar to this: http://stackoverflow.com/questions/905447/how-to-prevent-listbox-selectedindexchanged-event, but I want to ask it a different way. Is there a simple way to determine if the 'SelectedIndexChanged' is coming from the user as opposed to initiated through code (e.g. ListBox.SelectedIndex = x)? ...

Can't save data in database help!

I have an widnows form aplication and i can't save the data from aplication(textboxes) in the database (ms access). The stored data is seen in the aplication, but if i open the database it's not there... so if i open the database and restart the form aplication i don't see the before inserted data . string conString = "Provider=Micro...

Pesky NULL checkbox in SSRS report

I'm using the ReportViewer control in a WinForms app. How do I change the "NULL" checkbox text to anything else? (just right of 'Begin Date' in the below picture) ...

Interop Forms Toolkit DLL and "Class does not support Automation or does not support expected interface" error

I have a .NET WinForms application that I've converted into a COM dll using the Interop Forms Toolkit 2.1. Thet setup project for the application has both my tlb as well as the Microsoft.InteropFormTools.tlb file set to Register as vsdrpCOM. The prerequisites for the project are to ensure that Windows Installer 3.1, .NET Framework 3.5 SP...