winforms

What's preventing me from resizing (downsizing) my windows form object?

I've got a windows form object that contains 3 objects, a treeview, a richtextbox, and a tabcontrol. They are not docked into the windows form, but they are anchored (top+left). I've written the code to resize them when a form-resize event handler gets called, but it only seems to be working for an increase of form size, that is to say...

Why is my notifyicon application not exiting when I use Application.Exit() or Form.Close()?

I have a Windows form application which exit to a system tray Notifyicon and I have tried calling Application.Exit() or Me.Close() to close the program. But neither works to close the program. What is the correct way to close it? ...

How to detect changes in any control of the form in C#?

Hi fellows, Could someone help me in detecting changes in any control of the form in c#? A i have many controls on one form and i need to disable a button if anyof teh control value in the form changes.I am in search of some built-in function/event-handler/property, and don't want to make a customized function for that. Please guide me...

How to bundle a .wav sound into a Winform application .exe executable?

I have a alarm clock Winform program with a .wav sound. I would like to bundle the sound file into the exe file so that it is easier to distribute. How can I do this? ...

ComboBox AutoComplete

Is there anyway to have the autocomplete for a combo box to start from anywhere in the text, let me give you an example. If I have someone named john smith in the combobox if I start with the letter 'j' it pulls up john smith but less say I want to start with the letter 's' to search for his last name, is that possible, if so does anyone...

How to interrupt a constructor of window form ?

I have a simple application: static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } } Co...

How to bind combobox from datatable in winform having text and byte[]

How to bind a combobox with the datatable containing two columns. String and Image. When I am setting valueMember then an error is thrown. Argument Exception was unhandled Cannot bind to the new value member. Parameter name: value ...

Fields validation in winforms

Is there a shortcut in validating fields in winforms? For example a particular textBox is required to be filled up before saving a record. What I always do is I check first all the required fields programatically before saving. Example: protected bool CheckFields() { bool isOk = false; if(textBox1.Text != String.Empty) { ...

Windows forms: PropertyGrid

Hi, Does setting PropertyGrid.SelectedObject = null; effects the actual object? eg: Button b = new Button(); System.Windows.Forms.PropertyGrid pg = new System.Windows.Forms.PropertyGrid(); pg.SelectedObject = b; pg.SelectedObject = null; What will happen to Button b? will it be null? Thanks & regards, Vishal. ...

DataGridView rows can't change their background color at the initialization stage

Hello everybody! I have the next problem: TabControl has three TabPages. Every TabPage has its own DataGridView. On "Enter" event some rows change their background color. When the form begin to initialize, the function, that changes color, is called. But DataGridView rows have their default background (background color hasn't been chan...

Can't insert a picture into RichTextBox

I want to insert a picture into a RichTextBox. I add the picture in coding. This is the major code, adding a jpg image: MemoryStream memoryStream = new MemoryStream(); img.Save(memoryStream,System.Drawing.Imaging.ImageFormat.Jpeg); byte[] bytes = memoryStream.ToArray(); String width = img.Width.ToString(); String height = img.Height.To...

WinForm: Represent a single ListBox item in a foreach statement

How do I repesent a single item in a list box in a foreach statement? I have tried ListBoxItem but System.Windows.Controls is not considered a valid namespace in my .Net framework (version 4). foreach(ListBoxItem item in listBoxObject.Items) { ... } ...

SetCompatibleTextRenderingDefault(true) and Graphics.DrawString() text rendering

I'm writing a C# (ActiveX) plugin for an application that uses SetCompatibleTextRenderingDefault(true) (forces .net 1.1 text rendering style) This setting mangles some of the text I output with Graphics.DrawString() causing it to look slightly smudged and bolded. Unlike individual controls neither the Graphics class nor the BitMap don't...

Why does the '{' throw a NullReferenceException in a static method?

This one is sort of esoteric. I ran into a NullReferenceException while trying to open a form (in the winforms designer) in a winforms project in visual studio 2008. The stack trace points to the fourth line of the following code: public static class Logger { public static void LogMethodEnter() { var frame = new StackFr...

WinForms DataGridView Alternative

I need to populate a list that has 3 columns. First: Icon Image. Second: A string. Third: A string. I started to wire up a DataGridView and it seem awfully large and powerful for my needs. I am not interested in displaying data in a grid similar to a spreadsheet and I do not require all the functionality that comes with this control. I...

Launch a winform application from a windows service

Hi, Please let me know how do I run the app under current logged in user from the service. To give you background, I have a VB.NET Windows service whose sole functionality is to run a Winform App at a specified time. Apart from that it also sets a system wakeup timer so that the system can be woken up at the specified time, if it goes ...

Required Dialog for selecting Multiple Files and Folders .NET

I thought it would be easy to find, I was wrong. Dialog Requirements: Can browse MULTIPLE FILES/FOLDERS in the same time. Can be used in .NET windows forms. FREE or can be used under GPL. Works in Win Xp and Win 7. Dialog Preferences: C# Looks like OpenFileDialog in .NET. Has textbox for pasting path. I have tried few examples f...

WinForm: Obtain values from selected items in a List Box

How do I obtain the values (not displayed text) of all the selected items in a List Box? My intention is to use the values (which represent primary and foreign keys in my databases) to assemble a sql query. Specs: Using WinForm with a .Net Framework v.4 ...

[Solved] Using IDataErrorInfo on related but non-mutually exclusive checkboxes

I have a series of checkboxes on a form. One or more must be checked, and if not I want to display an error icon on them until one of them is. My IDataErrorInfo implementation looks like so: public string this[string columnName] { get { switch (columnName) { case "option1": case "option2"...

How to quickly reach a subchild in XML?

I have an XML file full of this: <machine id=""> <application id=""> <fichier name=""/> <fichier name=""/> <fichier name=""/> </application> <application id=""> <fichier name=""/> <fichier name=""/> <fichier name=""/> </application> </machine> I know the id of machine and application and the name of fichi...