winforms

How to keep Font in inherited TextBox?

Hi SO-lers, I'm using the following code to get a TextBox that is not drawing its borders: public partial class CustomTextBox : TextBox { public CustomTextBox() { InitializeComponent(); SetStyle(ControlStyles.UserPaint, true); } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); int borderWidth = 1; ...

How do I show a custom palette in the Designer?

Our graphic designer would like us to use his colour palette for our winforms application. Is it possible to display this palette in the designer, similarly to the system palette, rather than having to enter the colours by hand every time? ...

Binding DisplayValue to a different Source than the Control's DataSource

Say I have Tasks and Employees, each with their respective table in the database. There would be a many to many relationship between them, and as such there would be a third table for Assignments. If I create a listbox that is bound to a AssignmentsBindingSource I do not have the name of the employee to display. Is there a way to get ...

How to make scrollbars appear in a resizable panel when the contained control is too big for it ?

I am developing a Windows Forms application (.NET 2.0, VS 2005). I have a form that essentially contains a panel that is dynamically resized with the form : this.panel1.Dock=DockStyle.Fill; This panel is simply used as a container. At runtime, a custom control will be added : UserControl uc=new UserControl(); panel1.Controls.Add(uc);...

appSettings not being read from machine.config in Vista

I've recently moved up to Vista x64, and suddenly, my machine.config appSettings block isn't being read by any .NET assemblies. Right after configSections, and before configProtectedData in C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config, I have: <appSettings> <add key="foo" value="blah"/> </appSettings> <system...

How to filter C# Winform datagridview that was created with Visual Studio

I'm astonished there isn't even a filter property attached to datagridview and I'm getting on my nerve, I can find examples for filtering Datagridview that was binded programmatically, I cannot find any example on how to filter a datagridview that was generated by Visual Studio. So please can someone tell me how to filter this stuff ? ...

Why isn't my exception being caught

I have an application that is mixed Winforms and WPF. In Winforms, I have a global exception handler that is defined as follows: AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Application.ThreadException += Application_ThreadException; This ALWAYS catches exceptions anywhere in my application that occu...

Calendar Control 12.0 Refuses Input

In Microsoft Access, I have a series of forms that require the user to specify a date range. Right now I do this with Calendar Control 12.0. However, at random times, the control refuses to accept any user input (such as changing the date). Why would the Calendar Control refuse input? Is there any known workaround for this? I'm runn...

How to call a Web Service Method?

I have a web service that contains this method: [WebMethod] public static List<string> GetFileListOnWebServer() { DirectoryInfo dInfo = new DirectoryInfo(HostingEnvironment.MapPath("~/UploadedFiles/")); FileInfo[] fInfo = dInfo.GetFiles("*.*", SearchOption.TopDirectoryOnly); List<string> listFilenames = new List<string>(fInfo....

Windows Form Click on Background to move Window

I have a borderless window (BorderStyle = None) where I would like to allow the user to click on the background (anywhere but one of the child controls) and move it around. How would I go about doing that? Thank you, ...

System.Windows.Forms.WebBrowser.Print() displays print dialog

From MSDN: This method prints the current document without requiring further user input. To display the Print dialog box prior to printing, use the ShowPrintDialog method. But when I execute .Print() in my code, I always get the normal Windows printer dialog box. My question is simply: how do I avoid display of the printe...

VB.NET WinForms ListView Question

Hey. I have a ListView with 3 columns, how do I add specified text to the specified column I want? I've looked at the ..Add function, but it doesn't take the column index.. Thanks! ...

c# winforms context menu events problem

I added a context menu (add, cancel) to tree view dynamically. Now I want to show the selected tree node value when I click on context menu item click. How can I do that? ...

How to create WinForms components based on the type of an object

Lets say we have this interface: interface IVehicle { ... } And some classes implementing it: class Car : IVehicle { ... } class Boat : IVehicle { ... } class Plane : IVehicle { ... } In my user interface I have a FlowLayoutPanel and access to some sort of an IEnumerable<IVehicle> with a number of various IVehicle objects. Now I ...

How do I capture the enter key in a windows forms combobox

Hi! How do I capture the enter key in a windows forms combo box when the combobox is active? I've tried to listen to KeyDown and KeyPress and I've created a subclass and overridden ProcessDialogKey, but nothing seems to work. Any ideas? /P ...

Why is RichTextBox ignoring \fs in my RTF?

I'd like to use a RichTextBox to display some text in the start page of my WinForms application, as follows: richTextBox1.Rtf = @"{\rtf1\pard\fs40 Hello World\par }"; The RichTextBox ignores my font-size directive (\fs40). It works in both Word and WordPad. What am I doing wrong? ...

Why this DataBinding does not work?

I really don't know why this doesn't update the database, Anyone can help me? SetMasteraAdapter(clsLabWork.LabWorkMaster, "LabTestMaster"); dtaMaster.UpdateCommand = new SqlCommandBuilder(dtaMaster).GetUpdateCommand(); txtLabNo.DataBindings.Add(new Binding("Text", dtsMaster, "LabTestMaster.LabNo")); txtSaleMan.DataBindings.Add(new B...

Winforms ListView Selection Drawing?

Is it possible to override the listview detault selection paint? The one that looks semi-transparent blue overlayed over the items, like in the explorer windows. I want to draw an outline around the selection to indicate selection. Any way to do this? Examples are appreciated. ...

Scroll to bottom of C# TextBox

I have a TextBox on a C# Forms Application. I populate the TextBox with information on the Load event of the form. I then call the following: this.txtLogEntries.SelectionStart = txtLogEntries.Text.Length; this.txtLogEntries.ScrollToCaret(); However the TextBox does not scroll to the bottom ? This only applies to the Load event though...

How do I get a list of components from a control?

I have a component derived from ErrorProvider. I have a BaseForm and BaseUserControl that each have this custom ErrorProvider added in the designer. I have many nested BaseUserControls on a BaseForm and on other BaseUserControls, and I need to find all of the custom ErrorProviders on the nested controls from a top level form or user co...