winforms

User Control - Custom Properties

Hello All, I have developed a User Control in Visual Studio (WinForms C#) and have a question. I need the user of my User Control to be able to change certain string values and I would like them to be able to add the user control to their Form and click on it to bring up the Properties Pane where my User Control's custom properties wil...

How to mark a property as ReadOnly even if GetCreateInstanceSupported = true in winforms, .net

Using the CreateInstance method of the TypeConverter class, it's possible to edit the properties of an immutable object - such as a font. However, unlike the font class, there's some properties in my class that i'd like to be browsable but readonly - even though CreateInstance is supported. Is there an attribute that supports this? ET...

Data Binding Dissimilar Types...

Trying to accomplish: I want to change the image property of a bound tree node when the value of an enumerated property changes on the bound object. Bound Object is representation of an airfield or vehicle base in a game. The object has a property of Type which is an enumerated value type: SmallAirfield, MediumAirField, LargeAirField, ...

C# PropertyGrid: Changing properties not working?

I have a property on my World class that looks like this: public Vec2 Gravity { get { Console.WriteLine("Getting gravity!"); return GetGravity(); } set { Console.WriteLine("Setting gravity!"); SetGravity(value); } } The "Getting gravity!" str...

how can I add a custom non-DataTable column to my DataView, in a winforms ADO.net application?

Hi, How could I (/is it possible) to add a custom column to my DataView, and in this column display the result of a specific calculation. That is, I currently have a dataGridView which has a binding to a DataView, based on the DataTable from my database. I'd like to add an additional column to the dataGridView to display a number whic...

Creating Wizards for Win Forms in C#

Is there any framework or tutorial on how to create a wizard in C#. I need to provide the user a way to do a sequence of selections/user inputs. I thought Wizards would be an ideal way. I need Next/Back buttons on each page. I haven't created wizards yet. Any inputs would be very helpful. ...

How to re-shape form?

I have a form in an application developed using C#. In that form I have created a graphic shape (a circle). At run-time I want my form also to be of that shape only. That is, I want to display only that graphic and not the form back ground or title bar or anything. I want to display only that graphic. But the thing is I'm not able to sha...

Delete selected row from datagridview and update DB

Hi all... I have a datagridview and the user will select a row, then click on a Delete button. The row should then delete AND the DB needs to update using tableadapters. How can I do this? The code is in C#... This is what I have so far: private void btnDelete_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRow...

Leave Win Form Local DB Connection Open?

Hi, First up, I understand why it is good practice to close server database connections as soon as possible. I am developing a program that will contain a local database (5 tables ~ 200 columns), it may grow to a few thousand rows (so doubt it will be too much of an overhead). My first thought was to keep the local db connection until ...

Disconnected or Connected Architecture

Is a disconnected architecture too complex for the following story line? I'd be grateful if anyone could share any opinions or experiences that they may have. There is a business application that runs inside the office network which consists of a desktop application and a SQL Server database. Some of the data is exposed to the general p...

Windows.Forms.NativeWindow is null

In our SDK (DotNET SDK for an unmanaged C++ application) we offer a way for plug-in developers to get the main window of our application. public static System.Windows.Forms.NativeWindow MainWindow() { System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess(); if( null==process ) return null; IntPtr ha...

DataGridView get current selected object

Hi, I need to get the currently selected object from da databound DataGridView. I do not need the object of the current selected cell, but the object on which the whole row is based, in this case a BusinessObject whos properties make the columns of the grid. I could go over the DataSource, but that itself is just an object and can be ...

How to Make Sure UI is Responsive Using BackgroundWorker

Is BackgroundWorker in c# Thread Safe? The reason I ask this is because I get a Controls created on one thread cannot be parented to a control on a different thread exception with it. This is my DoWork event code: private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { var openFile = document.Open(My...

How can I prevent other apps from stealing the focus?

I have a fullscreen window with the Topmost property set to true. Whenever an application changes its WindowState property, my window is automatically minimized even though it has the active focus. For example, the code below exemplifies the problem. 3 seconds after the window is deactivated, it changes from Minimized to Normal, minimizi...

ListView.View = View.LargerIcons;?

I have a WinForms .Net 2.o app with a ListView in it and i'm trying to show some thumbnails. I set the listView.View-property to View.LargeIcon, but that's not big enough. I would like to have thumbnails about 250x180. Is this possible? And if, how? ...

.Net Localization Question. Japanese Characters Display as Squares.

OK, I don't do much .Net programming, but I do have one that I maintain, so the answer to this may be obvious. Setup: Windows 7 Ultimate with All Language Packs Installed Visual Studio 2008 Winforms VB.Net project. I'm in the process of localizing this project, and when I'm making the Japanese version of the forms, the characters di...

Black background before loading a wpf controll when using ElementHost

I'm using WPF in WinForms with ElementHost. When the form loads, there is a flash of black background where the ElementHost is about to load. This looks kind of bad. Any suggestions on how to get rid of this? ...

Background Process (periodic "service") in WinForm Application

What is the best practice for setting up a background process that runs every 10 minutes in a WinForm project? Is it to use a backgroundworker off of the form? Or is there a more generic way that would apply to many more project styles? Maybe some code I should call right before the line: Application.Run(new Form1()); ...

track changes in winform C#

Hello i have a form, which hosts a tabcontrol. each of these tabs have plenty of controls ranging from textbox, combobox, treecontrol, spin controls. On top of the form there is a textbox. if there are any changes made using the controls of the forms say a value is changed in the combobox of tab 1 or a item was deleted from the tre...

Disable and Enable Screen Saver in Windows 7

I have an application than disables the screen saver temporarily in order to run a slide show. I use this to turn it on or off: i = SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, active, Nothing, SPIF_SENDWININICHANGE) This works fine in XP. In Windows 7, it disables the screen saver properly. However, when it is enabled again, at the ...