winforms

Clearing controls from FlowLayoutPanel not calling destructors?

Sorry if I'm missing something obvious, but I'm trying to clear the controls (a series of user controls) from a FlowLayoutPanel - (panelName).Controls.Clear();. Unfortunately this doesn't seem to be calling the destructors for the objects on the panel - the User Objects column in the task manager just keeps going up and up, until it hits...

Set focus to another control after TreeView click

I have a TreeView control in a Windows application. I am opening another window from the TreeView click (Single Click) event (in tabbed environment, so all windows will appear as a tab in Visual Studio). I want to set focus to one control of the new window. The problem is that, I am able to set the focus on the double click event of th...

DataGridViewPaintParts enumeration backgrounds

With regard to the DataGridViewPaintParts enumeration, there are three kinds of background within it: Background, ContentBackground and SelectionBackground. What does the ContentBackground draw? I can turn this on and off by using e.PainParts within the DataGridView RowPrePaint event, but it doesn't appear to do anything. MSDN is less...

DataGridView - "Cell Selection Style" - Edit Cell

I'm working on a WinForm client with a DataGridView control. I notice users have to click once to select the cell and again to edit it. What is the way to change this to a single click edit mode? I thought I had seen something like this before but can't remember the name. ...

Organization of folders on VS Solution

Well, Im a little worried about where to put the user controls and the forms (childs and parents), the helpers classes and so on. So Im using RepositoryPattern for DataAccess and my Forms was added in the ViewLayer with any organization. I want yours opinions about using some Architecture for deal with this, or just create some folders a...

Filename not being passed to main

I have an app and I have a file type associated with it. When I doubleclick the file it opens my app but the filename/path never gets passed to my app. It does work if I drag the file over the icon, however. Here is the main(): static void Main(string[] filenames) { Form1 form = null; Application.EnableVisualSty...

Custom TreeView OnDrawNode is never called

I have created a custom tree view control in .NET to display directories. What I want is for the nodes to display the folder name and also the date last modified. I can do this by just setting the text to include this but then when I try and get child nodes using full path it also includes the date and so the folder is not found. So I...

How to detect Ctrl - Forward Slash in WinForm app

Below is the code for Ctrl-F (from another SO post). But how do you detect a Ctrl-ForwardSlash? or Ctrl-Slash (note: divide does not work) protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (1 == 1) //keyData == (Keys.Control | Keys.F)) { MessageBox.Show("What the Ctrl+F?"); ...

Add item to right click menu

I'd like to add an item into the right click menu (like TortoiseSVN does, or 7zip etc...) I'm not sure how to do this or what it is specifically called. It would be preferable if this option was only available while my program was running. Use case: User would select some text on a webpage (or word document or anything on their compu...

Transparency around non-rectangular (owner draw) ToolTip control?

I'm customizing the appearance of a WinForms ToolTip control by responding to the Draw event. I just want some of the ToolTip's corners to be rounded. I've got everything working such that the first time the ToolTip is displayed, everything looks perfect. On subsequent displays, however, the unfilled areas of my rounded rectangle continu...

C# WinForms Panel Problem

Hey, I have an annoying problem - I want to use a listview with images as Menu. Let's say the listview contained 3 "images". Image 1. ) "Main" Image 2. ) "Options" Image 3. ) "Misc" Now when I click the "Main" image, I would display the "Main" panel, same for "Options" image where I display the "Options" panel. but here's the annoyi...

Listbox ClearSelected method leaves items selected

Hello, I have several winforms listbox controls I am hosting in a user control. The behavior I want in this user control is that I only want ONE of the listboxes to have a selected item at a time. So if I have an item in Listbox1 selected and I click an item in listbox2 listbox one should be automatically have all items deselected. ...

Unexpected results in Linq query

I have a Linq query that looks something like this: var myPosse = from p1 in people select p1; label1.Text = "All my peeps:" + Environment.NewLine; foreach (Person p in myPosse) { this.label1.Text += p.ToString() + Environment.NewLine; } This gives me good results. But when I do something like this: var myPosse = fr...

update control on MainForm from separate class method.

Hello, I have a simple app with a MainForm that sometimes opens a second form. I have a Data Access Layer Class .cs and that has try catch statements. On a catch I call another class method logError. Since logError can be called by any thread or from the 2 forms, it's in a separate class on its own. What I would like is that if logEr...

How to avoid a series of "if" statements?

Assume, I have a form ...lets say WinForm... with 'n' number of controls. I populate them with a default value during the LOAD. Then, the user gets to play with all the controls and set different values for the controls and submit the form. Here is where I find myself writing a series of "if" conditional statements handling the value o...

Max Char in TextBox C#?

Just wondering how many char can C# Textbox multiline hold? ...

Picture Box image source is it possible ?

Hi I want to set dynamic path to my picture box in winforms. Is it possible to do like this my image is here some thing like http://www.indianorphanages.net/images/india-political-map.gif now I want to bind it to picture box (winforms) Is it possible? ...

How to databind to a dropdown list of user defined types?

I have a dropdown list containing the days of the week - Monday to Sunday. It is populated with a user defined type of two values that map the numeric day of the week to it's name. Public Structure WeekDays Public ID As Integer Public Text As String Public Overrides Function ToString() As String Return Me.Text End Fun...

ListView version of ListBox.SelectedItem

hi all i'm trying to perform an action once the user double clicks on an item in the listview. but there doesnt appear to be any methods available for this. can anybody please help me out here? thanks lots :D ANSWER (Thanks to Kyle's link): private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) { if...

C# Creating form from System.Threading.Timer tick fails

Hi When using System.Threading.Timer, and initializing a windows form on the timer's tick event, the form becomes unresponsive. Why is that, and how can I avoid it? This simple sample code shows the problem; the two first windows ("Original" and "Manual") works fine, but "Timer" becomes unresponsive at once. using System; using System...