winforms

DataGridView, DataTable, SqlDataAdapter and SqlCommandBuilder - disable deletes

I have a WinForm that has a DataGridView table. It is bound to a DataTable in conjunction with a SqlDataAdapter and SqlCommandBuilder. What is the best way (easy and easy to manage) of disabling Deletes but allowing Selects, Updates, Inserts? Is there a one line property I can set on the grid? That is how I would prefer to do it. ...

The application freezes when closing WebBrowser controls

I am new to WinForms and I'm trying to use the WebBrowser control on GNU/Linux with Mono. It runs fine, but when I close the form I get strange warnings, and the application freezes when I try to create another form containing a WebBrowser. In fact I can launch as many browsers as I wish, until I close one. Then if I create a new one th...

C# Tell If Form Is Maximising

Ok heres my problem. I have a form that when it is not maximised, its maximum size has to be the total height of the components inside the form. To achieve this, i use this: private void resize_form(object sender, EventArgs e) { this.MaximumSize = new System.Drawing.Size(1000, this.panel4.Height + this.label2.Height + this.HeightMin...

Access Form Members with an integer?

Hello, In theory the whole thing I'm trying to accomplish is stupid from object orientated point of view,but I have to do it. Its an Online game I'm working on.The client has an inventory with items,you know - virtual items. The server sends the items with their corresponding position in the inventory. This is how my inventory looks l...

How to deploy SQL and attach DB: With ClickOnce?

I need to deploy a winform app that uses multiple db's. I need to deploy them with my app as they interact locally. Can I use ClickOnce or should I be considering a different approach? I found a couple of examples for ClickOnce but they all assumed that the DB is included in the Solution, which isn't the case here. THis app used ...

Creating and executing a Merge Replication programatically

Let me preface this by saying I now realize how stupid I am and was. I have been developing for 1 year (to the day) and this was the first thing I wrote. I now have come back to it and I can't make heads or tails of it. It worked at one point on a very simple app but that was a while ago. Specifically I am having problems with Local...

How do I center controls without resizing them? (.net Winforms)

I have a fairly simple user control that represents a basic login control. So it has a couple labels, text boxes, and a button. I would like this user control to fill its container, so I have set its dock mode to fill. So far easy enough. Now, I would like all the controls in my user control to be centered based on whatever size my...

Console UI in Winform App

We have a legacy application running on UNIX. Our windows users login to the application via a terminal application or commaind prompt. The app looks like one of those car-dealer like application which runs in dos mode interface. I am creating a new winform interface to the application but still want to keep the legacy application onlin...

How to save rich text from a web application and display it in a rich text box

I'm working on an application with a co-worker at the moment - she is writing a web form that allows users to enter and manage text that will be saved to the database and then displayed within a desktop application. I'm using a Rich Text Box to display the text from the database. We want to allow the users to use basic formatting (bold,...

.NET Winform - thumbnail of usercontrol

I have an app which uses some usercontrols. I want to take a thumbnail image of the usercontrols when they are loaded for use and add them to a flowlayout panel. Where can I find information on making a thumbnail image of a usercontrol when it's loaded? ...

expose and raise event of a child control in a usercontrol in c#

Hi i have a UserControl which contains the textbox within, i wanted to access the textchanged event of the textbox, but in the event properties of the usercontrol i don't see the events for the textbox. How can i expose and handle particular events of the child controls from the publically exposed UserControl in Winforms with C#. ...

Does data binding work on invisible control?

This is a .net problem with winforms, not asp.net. I have a windows form with several tabs. I set data bindings of all controls when the form is loaded. But I have noticed that the data bindings of controls on the second tab do not work. Those bindings work only when the form is loaded and when I select the second tab. This brings the s...

C#/winforms: how to best bind a propertygrid and a System.Data.DataRow

hello, i have System.Data.DataRows with several fields, most of them just plain types like int, single, string. what is the best way to make them editable using a propertygrid? it should work automatically no matter what kind of fields the datarow has, but it should not display all of them. i want to provide a list of properties that s...

Close another process when application is closing

I have a C# winform application that during its work opens another Winform process. The other process has UI of its own. When I close the parent application, I want the other application to be closed automatically. How can I achieve that? Thanks ...

How do you highlight the row and/or column labels of a datagridview on mouseover of any cell (in c#)?

With a DataGridView control on a Windows form, when you move the mouse over a row label (or column label) it's (the label cell) background changes to a shade of blue (or other colour depending on your Windows colour scheme no doubt). I would like to produce that effect when moving the mouse over any cell in the grid - i.e. highlight the...

Should I use Screen.PrimaryMonitor or Screen.AllScreens for setting Form.Location?

As the question suggestions, should I be checking the Rectangle to set a Form.Location (which is taken from a Settings file) based on: 1. if (settings.X < Screen.PrimaryScreen.WorkingArea...) { // Set the form's Location based on the settings object } or 2. int width = 0; foreach (Screen screen in Screen.AllScreens) { width ...

Show a child form in the centre of Parent form in C#

I create a new form and call from the parent form as follows: loginForm = new SubLogin(); loginForm.Show(); I need to display the child form at the centre of the parent. So,in the child form load I do the foll:` Point p = new Point(this.ParentForm.Width / 2 - this.Width / 2, this.ParentForm.Height / 2 - this.Height / 2); this.L...

Control that gets a tab stop twice

In a standard WinForms application, is it possible to have a scenario like the following and how would I do it: A form with four textbox controls, arranged on the form from top to bottom: TextBox1 TextBox2 TextBox3 TextBox4 The desired behavior is that when the form loads, the focus is on TextBox3, but when tabbing out, the focus go...

Why does text drawn on a panel disappear?

Hello, I'm trying to draw a text on a panel(The panel has a background picture). It works brilliant,but when I minimize and then maximize the application the text is gone. My code: using (Graphics gfx = Panel1.CreateGraphics()) { gfx.DrawString("a", new Font("Tahoma", 5), Brushes.White, new PointF(1, 1)); } How do I keep it sta...

What's the preferred method for storing user settings in a .NET windows app?

Pardon my ignorance, but I've never really developed windows apps. How do you store user settings? Is an embedded database the preferred method? ...