winforms

How to set GridLayout for WinForms control i.e. Panel

How can one set GridLayout known from Java or Wpf in WinForms control? Is it available by default or does it require writing some code (custom LayoutEngine implementation)? ...

WinForms aplication UI is influenced by Windows UI settings

How can I make sure that my applicaiton User Interface is not influenced by Windows UI settings? What changes should I do to my application in order to prevent it? ...

Which executes first? Form_Load event or the initialization of components? (C# windows form)

Which executes first? Form_Load event or the initialization of components? (C# windows form) ...

Databinding a datarow on Controls in Panel

Hi, I am making a custom control based on a Panel. The main idea is to bind a datatable to this panel. There are functions for selecting a row + updating, saving and deleting this row in the custom Panel. The only problem is binding the data. I have this function: private void _addBindings() { _src = new BindingSource(...

How can I find the active child window?

How can I find the active child window (like focus Edit in modal dialog). I know how to enumerate child windows, but I don't know how to detect if a child window is active (focus). ...

System.Windows.Forms.Trackbar - how to prevent user from dragging the slider?

Is there some way to (temporarily) prevent user from changing the value of TrackBar by dragging the slider? Only way I found is to set Enabled property to false but it also greys out the trackbar. Edit: Since I´m getting more answers about why shouldn't I do it rather than how it's possible to do it, I decided to explain why I would li...

styling C# forms

Hai am developing a project in C# windows application it includes 22 forms, for styling (i.e. font, backcolor,italic,cell color,text fore color) controls for all form i create a function but i have a problem in that, it throws a error like this My code: foreach (Control cnn in gbsty.Controls) { else if (cnn is Label) { if (cnn.Name==...

Binding forename and surname fields to a label?

I have a table associating an ID with a client's forename and surname (two separate fields). I have a TextBox on my form for a user to enter a client ID and I'd like a live update of the name displayed on a label, e.g.: TextBox: 1 --> Label: "Sam Pell" (user types 1) TextBox: 12 --> Label: "Andy Other" (user types 2) I have t...

How Can I Customize Date Format

One of my table column's named "SetDate" of type DateTime looks as: 2010-08-02 02:55:58.420 The DateTime format from the application looks as: 2/11/2010 The problem is: I'm passing an SQL query to the DB via application. The query has WHERE clause which compares SetDate to the date coming from application. SetDate column carries ...

How do you add an OnLoad event to an IronPython WinForm?

I'm having a problem getting the OnLoad event called from an IronPython script that uses WinForms, I've reduced the problem to the smallest possible reproduction case: from clr import AddReference, accepts, returns, Self AddReference("System.Windows.Forms") AddReference("System.Drawing") import System from System.Windows.Forms import *...

How to avoid winforms treeview icon changes when item selected

Hi, I'm experimenting with a treeview in a little C#/Winforms application. I have programatically assigned an ImageList to the treeview, and all nodes show their icons just fine, but when I click a node, its icon changes (to the very first image in the ImageList). How can I get the icon to remain unchanged? BTW: The "SelectedImageIndex...

Persisting Data from the UI

I am doing a little testing with EF4. I have built a simple DB which contains one table: Table: Person Column: Id Column: Name I have a windows form application that contains a form with a gridview. I have the Model.edmx all setup and works correctly (tested without encapsulating the context). I have now encapsulated the context int...

How do I allow user to filter DataGridView (Linq to SQL, Winforms)

How do I allow user to filter the DataGridView with a Linq to SQL source? I want to allow the user to filter on any field, like you would expect from Access or Excel. With datasets, I could build up a query string and use that as a BindingSource filter. What's a good way do do the equivalent with Linq to SQL? I could write a LINQ que...

Better option for hosting MS Office documents in custom app?

I am currently hosting an IE Browser control in a .NET (2.0) Form and using it to load Office files such as Excel and Word thusly: _ieCtrl.Navigate("C:\\test.xls", False); The hosting and loading works well except whenever I navigate to a file I am presented with a dialog that asks whether I want to save or open the file. (This is sta...

Bar Chart in Framework 4 - Update issue

So I'm trying to update dataPoints programmaticaly in a column chart but whenever I do this, the column chart displays empty columns where there IS a number greater than zero, and displays a zero otherwise. Now the code below works for a pie chart but for some reason it does not work for the bar chart. barChart.Series(0).Points.I...

place a form with Opacity over a main form with datagridview winform

I have a form (named mainForm.cs) with a datagridview on it. I must to show a picture (with opacity) over a datagrdiview. To achieve this, I made another form (frmPicture) with a picturebox, and apply the opacity property to the form. It also set the opacity = 100 when the mouse get inside the form (frmPicture) and opacity = 30 when the...

How can I programmatically select or scroll to a TreeNode in a TreeView based on a string path?

Hello, I am implementing one of the common scenerios of a TreeView control and I am using a drives, files and folders. to make a File System. That means each node potentially has a path. Problem is, we have the ensureVisible method but am not entirely convinced this does what it says it does. There is no explicit 'setVisible' to false ...

WindowsFormsWebBrowser drag drop functionality.

Hi, I have a windows forms webbrowser (Windows.Forms.WebBrowser) I want to capture the drag drop event over it. I did not see any drag drop events on it that I can hook into ? It just has DoDragDrop() Could you please guide me as to how to capture the drag drop event on it? I want to handle these events in a parent control that hosts...

How to get ALL child controls of a WinForm of a specific type (Button/Textbox)?

I need to get all controls on a form that are of type x, I'm pretty sure I saw that code once in the past that used something like this: dim ctrls() as Control ctrls = Me.Controls(GetType(TextBox)) I know I can iterate over all controls getting children using a recursive function, but wondering if there is something more easier or str...

How to make a ToolStripComboBox look like a regular ComboBox

I am dynamically adding a ToolStripComboBox, and I need it to look like a regular combo box. The tool strip version has the editable field and looks completely different. Is there a property (or multiple properties) I need to set to make it look and feel like the default combo box? ...