winforms

change a particular cell in datagridview to be of type combo

i am binding a datagridview from custom datatable. i want a particular datacel to be of combo type. can it be done, if so how? in the code snippet below, if the key == "somevalue", i want to create a row where the datarow[1] will be of combo type. can it be done? private void UpdateDataTable(string key, object value) { if(dt.Rows.Con...

Adding An Overloaded Constructor To A WinForm

I have created a dialog as a winform and am calling that winform like this: Dim dlgEditChangeOrder As New dgEditChangeOrder Dim dlgResult As DialogResult dlgResult = dlgEditChangeOrder.ShowDialog ...pretty simple. I want to be able to set the visiblility of a control on the win form when the win form is called. I wou...

Showing WinForms dialog with focus from powershell script.

One of my coworkers just came to me with an interesting problem. He's displaying a WinForms form from a PowerShell script, and while the form opens successfully it does not get focus. Instead the PowerShell command window retains focus until the form is explicitly clicked. The script is being run from the PowerShell command line using ...

Sexy winform controls for C#

I am starting a new project and i need some very pretty controls. The ones that come with VS2010 aren't going to cut it. This application will be very simple, but I want it to look very appealing. Any suggestions for 3rd party controls that can help me do that? Open source, or pay. Thanks ...

How to prevent from moving forward until a background task is completed?

I have an external library which has a method which performs a long running task on a background thread. When it's done it fires off a Completed event on the thread that kicked off the method (typically the UI thread). It looks like this: public class Foo { public delegate void CompletedEventHandler(object sender, EventArgs e); ...

Wrapping Text in a rich textbox, but not word wrapping it

Hello all, I have a Windows Form with a Rich Textbox control on the form. What I want to do is make it so that each line only accepts 32 characters of text. After 32 characters, I want the text to flow to the next line (I do NOT want to insert any carriage returns). The WordWrap property almost does this, except that it moves all the te...

C#: "using" when instantiating a form?

I am looking at some C# code written by someone else. Whenever a form is instantiated and then shown, the following is done. Is this correct? Why would you use "using" in this context? MyForm f; using (f = new MyForm()) { f.ShowDialog(); } Additional question: Could the following code be substituted? using (MyForm f = new MyF...

C#: form in project not showing up in intellisense

I have created a form in a project. The new form is listed in the solution explorer as being in this project. But the form is not showing up in the intellisense listing when I try to create an object variable in order to show the form. Is there something else that needs to happen after you add form to a project? ...

C# Winform XNA Collision

I'm interested in knowing how I would go about detecting a primitive circle touching another primitive circle? So, if I had a circle with 5,10 and another one with 5,13 with each of them having a radius of 2. well the distance formula is the Pythagorean theorem. which is sqrt((x2-x1)^2 + (y2-y1)^2) = distance and if this distance is le...

Disable Excel Security Dialogs when using DsoFramer

I'm using the old DsoFramer control to embedded an instance of Excel in a form of mine. This has been working fine with Excel 2000, 2003 and 2007. Come 2010 however I think its behaving slightly differently. I now get a prompt about macros, which then blocks my UI until the user shifts focus to the excel instance in the background and c...

How do I associate a button with a control?

OR - How To Shave A Koala To Stop It Looking Squashed. (But I didn't think that would make a suitably techy title) The Problem: You have three preview images derived from a main image. The preview images are resized for standardised picture spaces on a company website, the main image can be any size image from anywhere. Example: The ma...

SQL Server Error "Could not open a connection to SQL Server"

Hello. I know this is a known issue. But I've tried everything I found out and I can't solve it yet. I've a .Net winforms app. It needs to connect to a SQL Server in a remote server in the same network. It works perfectlly in my machine, but it doesn't in antoher machine from my work. Both machines have Windows 7 and installed the SQL s...

Using a combobox for search criteria

Hi All- I am relatively new to winforms and C# and I am developing an application that will allow users to perform a search. To search the data they can use the following: -Combobox with 6 options -text box that they will enter info based on the combobox search selected. I have a stored procedure with a parameter for each of the sea...

how to deal with Unexpected date & time format's ?

hi i get date & time from Text file - to my string var in my C# program. i need to convert this string var to datetime var. how to do it, if i get unexpected type of date & time ? and if i dont know the type of region on the host computer (when i Spread my program) ? thank's in advance ...

Is it possible to have forms in sub-namespaces of a VB.NET WinForms project?

If I create a new class library project in VB.NET, I can create subfolders (a la C#), add WinForm objects to these subfolders, and then specify a namespace: Namespace Sub1.Sub2 Public Class SomeForm Public Sub New() InitializeComponent() End Sub End Class End Namespace This resolves as ProjectRootN...

Multiline Textbox Column in DataGridView

I want to have a multiline textbox to display data in a DataGridView. I found a solution here but that is not working for me. Here is my code that I am trying to fix the problem with: myDataGridView.Columns["Column1"].DefaultCellStyle.WrapMode = DataGridViewTriState.True; I noticed that I can scroll inside of the textboxes, but their h...

Windows MDI Child Form Title Bar

The MDI child forms, when shown, display their title bars for a split second. Then the forms are loaded normally. Is there any way for the forms to load without showing the title bar and form border. This is what happens... ...

How do I properly close a C# application that has created multiple threads?

I am writing a GUI application. The application is opening multiple threads during it's life time. One of the threads is handling events that can come from other applications, so it is waiting in a while(true) loop for the event which is never been terminated. The user can close the application in any minute. I want to close all the t...

.net 2.0 forms: Black margins appear when expanding form?

Create a .net 2.0 Windows form app, add a splitContainer docked Fill, with this in its form constructor: public Form1() { InitializeComponent(); for (int i = 1; i <= 300; i++) { FlowLayoutPanel f = new FlowLayoutPanel(); f.Dock = DockStyle.Fill; Button b = new Button(); f.Controls.Add(b); splitContainer1.Panel2.Controls.Ad...

strange exception which appears once in a while, could not reproduce the steps on WinForms UI

Hi Exception type: System.ComponentModel.Win32Exception Exception message: Error creating window handle. I could not reproduce it in development environ, although from time to time it appears at the end user. I know this may be a little too general and vague, but if you encountered such an exception what were the potential causes? ...