winforms

WinAPI magic and MONO runtime

I'm trying to get the same result of a .NET application (see the link Hide TabControl buttons to manage stacked Panel controls for details), but using the MONO runtime instead of the MS .NET runtime. Pratically, when the custom control is executed using the MONO runtime, the underlying message is not sent to the control, causing the tab...

"Collection was modified; enumeration operation may not execute." on form disposal.

"Collection was modified; enumeration operation may not execute." appears to be a common error with foreach loops, but I can't figure mine out. I have two classes of forms. One is begun on startup, and a button creates new instances of the second form, and displays them. When I close the secondary forms, I get an InvalidOperationExceptio...

"wait window nowait" in .NET

Is there something similar to "wait window nowait" in Windows Forms (.NET VS2008) ? This is a commonly used sentence in Visual FoxPro for debugging purposes and "quick and dirty" thermometers. ...

How do you place an Excel Sheet/Workbook onto a C# .NET Winform?

I am trying to create a stand alone application in Visual Studio 2008 C# .Net that will house Excel Workbooks (2007). I am using Office.Interop in order to create the Excel application and I open the workbooks via Workbooks.Open(...). The Interop does not provide any functionality to "move" the workbooks onto a form so I turned to P/I...

How to: generate UnhandledException?

I use this code to catch the WinForm application UnhandledException. [STAThread] static void Main(string[] args) { // Add the event handler for handling UI thread exceptions to the event. Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); // Set the unhandled ...

Iterating through tooltips

Guys, I have a windows form with a panel control and inside the panel control are several other controls with a System.Windows.Forms.Tooltip attached to them. How can I iterate through each tooltip and set the Active property of the tooltip to false? Tooltips, unlike other controls, are not actually controls. So I had this: foreach (Sys...

how do I get the index of a firing context menu item

I would like to determine the index of the selected context menu item. But I don't want to build a unique eventhandler for each menu item...how do I do this MenuItem mi= StatusContextMenu.MenuItems.Add("Set option"); mi.MenuItems.Add(0,new MenuItem("Set to A", new EventHandler(SetLetter)) ); mi.MenuItems.Add(1,new MenuItem("Set to...

How to customize an OpenFileDialog using nested types?

Say I wanted to customize an OpenFileDialog and change, for example, the way the filter for file extensions work, as in the case of this question. After I pointed out to the author of said question that the OpenFileDialog is not inheritable, I got a comment with the following: Even though the OpenFileDialog is sealed (not inheritabl...

Viewing Crystal Reports other than through custom developed webform or winform apps

At work we currently have a custom in-house built winforms app for the business users to view reports. It has role-based security and several administrator functions. My boss is thinking about getting me to port this app to webforms. My question is, are there options other than custom built winforms and webforms apps for deploying/view...

How to create custom context menu on title bar in .NET Windows Forms?

Hi, How can I create a custom context menu on windows title bar (like in Opera 10 or Firefox 4) that works on Windows XP and above? https://wiki.mozilla.org/images/e/e8/Firefox-4-Mockup-i05-(XP)-(Royale)-(TabsTop)-(Default).png Thanks in advance, Josh ...

Winforms fixed single border on custom shaped control

Hi all, I have created a custom control inheriting from a panel in .NET 3.5 The panel has a custom polygon border, which comes from a pointF array (In diagram, control is highlighted yellow). Fig 1 shows the control with BorderStyle none. Fig 2 with BorderStyle fixed-single As shown in Fig 2, the border follows the Rectangle bounding...

How to change "area" of a control in DesignMode?

When I drag and drop a TextBox from the toolbox onto a WinForm, I can drag it around on the form as I like. Now I create a new class and inherit it from TextBox. I add a new property called CaptionLabel. When set to a value, I dynamically create a Label control, set its value and finally add the label to the TextBox' parent controlcolle...

WinForms form freezes

On a form (F1) i have a button, from which if i create another form (lets call it F2) and show it there's no problem but i'd like to do something like this Some thread in my app is running a connection and listens for messages from a server. when a message arrives, my main form is registered to get an event that runs a function. From t...

C# Set combo item with selectedValue

I am dynamically creating a combobox like this: public Control GenerateList(Question question) { // Get a list with answer possibilities List<QuestionAnswer> answers = question.GetAnswers(); // Get a collection of given answers Collection<QuestionnaireAnswer> givenAnswers = question.GetFilledAnswers(); ComboBox cmb...

How Can i Populate Bulk of Data from a DB Table into a Combo Box? - C#.NET

MenuItem menus = new MenuItem(); GridView1.DataSource = menus.GetDataTable(); GridView1.DataBind(); menus.GetDataTable() returns a DataTable. In the above case, we are returning to GridView. I need to populate the data into a combo box. How can i do it? NOTE: Assume GetDataTable only returns records of a single column. I'm using Winf...

User Control creating and hiding a form Threading issues

I've got a control called ChatController, as a private member I have: private frmChat m_chatWindow = null; In ChatController's constructor I do: m_chatWindow = new frmChat(strJobNumber, m_emailAddress); if (m_chatWindow.InvokeRequired) m_chatWindow.Invoke(new MethodInvoker(delegate { m_chatWindow.Hide(); })); else m_chatW...

How to set ErrorProvider Icon left for all Controls programmatically

We use derived Form-Classes, with one base form class for our software. On the derived forms we use DataBinding extensively to deal with our BusinessObjects, all implementing IDataErrorInfo, throwing custom error-messages on false inputs to the GUI with ErrorProviders. I now search for a way to implement a function in the base-form-cla...

Saving data to a text file and loading it into a datagrid in C#

I need to Pass some data to a text file and save that text file in a SQL Server 2005 database. Then I'll need to be able to load that textfile into a C# WinForms DataGrid. How do I do that in C#? ...

Stop the form from closing on close button click?

Hi, If I have a close button on a form, and I want them to be able to click it but affectively act as a 'Hide' button, how can this be easily done? Is there no way to abort the FormClosing event from executing fully? Cheers ...

HELP! WebClient.UploadFile() throws exception while uploading files to sharepoint

In my application i am uploading files to sharepoint 2007. I am using using (WebClient webClient = new WebClient()) { webClient.Credentials = new NetworkCredential(userName, password); webClient.Headers.Add("Content-Type", "application/x-vermeer-urlencoded"); webClient.Headers.Add("X-Vermeer-Content-Type", "application/x-vermeer-url...