winforms

Winforms: SuspendLayout/ResumeLayout is not enough?

Hi, I have a library of a few "custom controls". Essentially we have our own buttons, rounder corner panels, and a few groupboxes with some custom paint. Despite the "math" in the OnPaint methods, the controls are pretty standard. Most of the time, all we do is draw the rounded corners and add gradient to the background. We use GDI+ for ...

Is this hWnd a child of mine?

How can I tell if an hWnd belongs to one of my child controls? I want to do something like: if(this.Controls.Find(hWnd) != null) return false; ...

Modifying the MouseWheel behaviour of a Combobox

I have a UserControl containing TextBoxes and ComboBoxes and this UserControl is contained in a Panel with AutoScroll set to True. When a textbox has the focus and I scroll with the mouse wheel, then the panel scrolls, when a combobox has the focus and I scroll with the mouse wheel then the selected item in the combobox changes. I'm su...

What am i missing... windows forms binding with subsonic

I have a form with a list box and a few text boxes, when the user selects an item from the list box, i need the approptiate information to show up in the txt boxes and allow the user to edit it. Here's my form Load event: Private prt As New DataAccess.Part Private Sub Form_Load(ByVal sender As System.Object, ByVal e As System.EventArg...

How can I get a value from a CheckBoxColumn using C# 3.0?

I can get the current selected row in this way: private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e){ //Cells[0] cause CheckBoxColumn is in that index (first column) DataGridViewCheckBoxCell temp = (DataGridViewCheckBoxCell)dgv.Rows[e.RowIndex].Cells[0]; } So, Now I want to get all of the rows that...

How do I create a Find form for a RichTextBox?

I would want to search up, down, and match case if possible. Even links to get me started would be appreciated. ...

Render a section of an image to a Bitmap C# Winforms

I'm working on a Map Editor for an XNA game I'm designing in my free time. The pieces of art used in the map are stored on a single texture and rectangles are stored with coordinates and widths etc. In the winforms application I can add segments by selecting the segment I want from a listbox, which is populated from the array of possib...

How to handle Copy for multiple controls when adding a ShortcutKey to menu item?

If I do not create an "Edit->Copy" menu item and assign it the shortcut keys "CTRL+C", then I can select a control (RichTextBox, DataGridView, etc..) and hit "CTRL+C" and the control itself will handle the copy. I can copy text out, and paste it into notepad, etc.. Now throughout my whole form, I have a lot of controls. But I have a cus...

Why is DrawString exhibiting unexpected behavior in C# Winforms?

I have subclassed a control in C# WinForms, and am custom drawing text in my OnPaint() handler. The font is set to Courier New using the following code in my form: FontFamily family = new FontFamily("Courier New"); this.myControl.Font = new Font(family, 10); In the control itself, the string is stored in realText, and I use the follow...

Calling a method on another form in C#

Hello, I am building a basic Image editor. In my app, if the user wants to resize the image a new form pops up and asks the user to input an new width and height for the image. public partial class Form1 : Form { ... private void resizeToolStripMenuItem_Click(object sender, EventArgs e) { resize resizeForm = new resize(...

how to deal with complex winform object databinding?

Hi, What are the best practices or tips with respect to data binding to objects? I have a complex data binding scenario where my winform has a BindingSource set to an object. This object is a class of type Customer and the forms are bound the customer's properties like "firstName", "lastName", etc. Each property has the following pat...

Why do I see 'Restricted' in my DevExpress.XtraEditors.DateEdit control

From a customer site we have a screenshot of one of our DevExpress date controls (DateEdit) showing the text 'Restricted' where the date is normally shown, has anybody seen this or know why it might happen. We've been unable to reproduce this in-house, I thought it might be the NullText for the control, but that just sets the control to...

How to keep window on top of another window in a different thread?

I have a WinForms form (call it 'MyForm') that hosts some WPF UI (via ElementHost). I show this form on a separate thread from the main UI thread. I want 'MyForm' to remain on top of the main application window, so I am showing the form using the Show(IWin32Window) overload of the Show method, with the passed-in IWin32Window being the m...

How can I programmatically click a TreeView TreeNode so it appears highlighted in the list and fires the AfterSelect event?

I have a TreeView control in a Winforms app, and basically the objective is to display a form that contains a TreeView control, and I want to display the form with a node opened (easy - EnsureVisible) and selected. The problem that I'm running into is that when I set the TreeView control's SelectedNode property, the node isn't highlig...

Get ListBox Displayed Height

Is there a way to determine the displayed height of a Windows Forms ListBox? In an application I am developing, I have a form with a ListBox docked in it. I need to automatically resize the form to remove the any extra space at the bottom which the ListBox does not use due to ListBox.IntegralHeight being set to true. Currently I am si...

Need IntPtr for a Form (VB.Net)

I need the intPtr for a form. Control.FromHandle(control) gives me the control from a handle, but I need the opposite--get the handle from a control. How do I do this? ...

DateTime nullable exception as a parameter

I have a Search Form that can search by a few different fields. The problem field is birthDate. On the form it is a string. In the SQL 2005 db it is a DateTime that can be null. The code below is sequential as far as declaring the variable on the form and then setting it. Then the call to the BLL and then the call to the DAL. On ...

webform or winform, how to choose?

What would be the normal way to decide which way to go? In my case, what if user-base was under 10 persons you have no control over CAS but can install the framework needed to import/export let say excel file/pdf would be intranet security is really important business logic is somehow complex ...

Windows Forms C#.net deployment issue

Hi there! I have just finished a WinForms app, and its working great! Now, time to deploy. Issue is, that I dont want to create a setup file, but rather a single executable, for example 'myApp.exe'. The reason for doing this, is because it will be redistributed on CD media, and it is supposed to auto-run as a stand-alone app when the C...

How to lock a window to another? [winforms]

I'd like my software to display a tutorial window when it first starts up and to have this window appear 'locked' to the right hand side of the main window such that, whenever I move the main window, the child will follow. How can I accomplish this? ...