winforms

Problem In updating a database through windows application.

Hi all.. I have a question. I am having problems updating data in an SQL database with Windows Forms (Visual Studio project). Here is what I do: I get user information in text boxes. I edit some of them. I do 1 back n get to this form again. The info is updated. When I quit and login again, it shows me the old data! It seems as ...

ToolStripSplitButton vs. ToolStripDropDownButton

What is the difference between ToolStripSplitButton and ToolStripDropDownButton? (Visual Studio 2008) (Also asked here, not on SO). At first blush, they seem to be largly the same; especially in the designer. ...

Windows Form TreeView - PNG Image Background

We are using famfamfam png icons. When TreeNodes are assigned one of these images there is an odd blue background colored inside the icons. How can we fix this? ...

How do you add a scrollbar to a Panel control with many controls in windows form application?

How do you add a scrollbar to a Panel control with many controls in windows form application? ...

What is the best way to get and set selection when using databinding in winforms?

I use binding in a win-forms application (.Net 2.0), and I try to find the best way to maintain the selected items in my data bound controls. I read that the best way to access the selection is by using CurrencyManager's (or bindingSource's) "Current" and "Position" properties. The problem is that I can't find a way to select nothing (Po...

Winforms DataBind to Control's Visible Property

WinForms, .NetFramework 3.5 Are there any known issues when databinding to a control's visible property? The control is always NOT visible regardless of what my property is. Public ReadOnly Property IsRibbonCategory() As Boolean Get Return True End Get End Property I tried the control's text property and other properti...

How do I loop through all layers of Treeview nodes?

Read EDIT 2 first I am trying to set up some way to visually distinguish the nodes in a winform app. For example, alternating colors. Can some one start me down that path? Also, has anyone else had to do that before and how did you do it? Thanks EDIT I had seen the backcolor setting as well(Thank You) but I am having trouble gett...

Closing a form from the Load handler

I have a very strange behavior that only seems to happen on one form. Basically I am creating an instance of a form, and calling Show() to display the form non-blocking. In that form's Load event handler, I have some logic that may call this.Close() under certain circumstances. This closes the form, but then the form Show method in the...

Master Form concept?

Like Master pages in ASP.NET, do we have any similar concept for Windows Form application. So that I dont have to repeat the same portion of form (Header and footer) many times through out the application. ...

Using combobox properties in C# NET 3.5

Hello, I'd like to know how to set a combobox to be read only,meaning the user cannot write text into it,but just select? Another question,how to determinate the text of the selected choice.For example it has index of 4 values(10,20,30 and 40).If the user chooce 20,how can I get the Text of the choice he selected(Not the index number,b...

How can I tell if my form is displayed beyond the screen?

So I have two forms, mainform and extraform. extraform is set always moved to the right of mainform when mainform initializes Sometimes mainform takes up both monitors and extraform is pushed off the screen never to be seen again. I would like to prevent this if possible. How can I do so? It must support dual monitors, that may or may no...

Generating non-anti-aliased fonts with WinForms

I have a requirement to generate a bitmap containing some characters rendered without anti-aliasing or ClearType. In Win32-land, I would have created a font with lfQuality set to NONANTIALIASED_QUALITY and drawn with that. I have tried to do this with WinForms in the following manner: using(Font smoothFont = new Font("Arial", 30, Gr...

How do I share MenuItems between a ContextMenu and a ToolStripMenuItem?

I have a context menu attached to a panel, that should mirror commands available in a toolbar menu. Currently in my MouseUp event, I set the enabled state of the MenuItems, and add them to the context menu: ctxMnuLinks.Items.Clear() ctxMnuLinks.Items.Add(mnuLinksOpen) ctxMnuLinks.Items.Add(New ToolStripSeparator) ctxMnu...

Why use Events?

I'm understanding how events work in C# (am a fair newbie in this field). What I'm trying to understand is why we use events. Do you know a well coded / architected app which uses events? ** rest of message snipped and put in as an answer** ...

Forms DataGridView missing OnRowDataBound?

Yesterday a colleague asked me how to display data in a grid where the built in data binding doesn't support what he wants to do for some of the columns. Pleased to be able to help I explained all about the OnRowDataBound event and how you can hook into it and dynamically manipulate the cells in the row object to do pretty much what you...

Compare different ways to remove selected items from System.Windows.Forms.ListBox

So far I've found 2 ways to delete selected items from a listbox (winform): 1. ListBox.SelectedObjectCollection tempCollection = new ListBox.SelectedObjectCollection(myListBox); for (int i = tempCollection.Count - 1; i >= 0; i--) { myListBox.Items.Remove(tempCollection[i]); } 2. while (myListBox.SelectedItems.Count > 0) { my...

how to create a datagrid in C#

here i am not using any database to populate value . i want to add a datagrid to a form .and when i execute it user enters value and i use them . i need a similar implementation of table for eg i have two columns and user enters values i use them for calculation . here i am not populating values from or to a database ...

Autofit WinForms RichTextBox to its contents

Does anybody know how can I dynamically resize a RichTextBox control to its contents? ...

Master Forms in windows form

Like Master pages in ASP.NET, do we have any similar concept for Windows Form application. So that I dont have to repeat the same portion of form (Header and footer) many times through out the application. ...

WinForms: How can I include a usercontrol form an external library?

I have a class in an external library subclassing UserControl and set to public. Now I want to use this usercontrol in my main WinForms app. I have added this external library to the references of the main app, but the user control haven't appeard in the Toolbox - I have been told it should appear. I am doing this for the first time. So...