winforms

How to build a multiple specific validation rule

Hi, I have an application that must be prepared to work in various companies. But I fear that every company needs specific validation rule. What is the better way to perform validation in my presentation layer without having to recompile my application for each client? ...

WordWrap in CheckedListBox control

I have a CheckedListBox in my Windows forms application, but items can be added that are to wide for the control to display. Is there any way to have the text wrap to the next line when this occurs? I know with a standard ListBox this would not work, since it would be hard to tell the difference between the second line of one item an...

Slow TreeNode with CheckBoxes [large quantity]

Tree View control's AfterCheck event checks all child nodes below it and enables the Run button if something is checked. 1346 void TreeNode_AfterCheck(object sender, TreeViewEventArgs e) { 1347 if (!e.Node.Checked) return; 1348 foreach (TreeNode sub in e.Node.Nodes) { 1349 sub.Checked = e.Node.Checked; 1350 } 1351 RunButton....

How to set the appearance of a cell in a DevExpress grid?

I am using a DevExpress XtraGrid in my project. I need to set the appearance of a specific cell (specifically, the background color). And I cannot find any property or method in the grid that does this! The only way I can see of doing this is by catching the RowCellStyle event of the GridView, and determining whether the given cell ne...

Best practices for closing winforms: cleaning up and last-minute application events

I have a variety of small C# winforms applications (though this should apply equally to any .NET app) which need to perform a few minor tasks when they are closed. I have been making use of the .FormClosing event to do things like write the current settings file and wait for background threads to finish, etc. Two questions came to mind...

Show amount of unread emails in C#

Hi I want to show how many unread emails I have in my inbox (gmail) and show this number in a label. e.g Inbox(3) I've tried a load of sites but couldn't get anything. I'm new to programming in general so any help would be great. ...

how to update datagridview and the database too ?

hi i have my C# winforms program that has datagridview. i know how to update database through sql query like this: update myTbl set Fname = 'xxx' where code = '2' but how to change any cell in the datagridview - and that change will influence my database too ? thank's in advance ...

connect custom list with control like combobox

I have table - custom id (like 1.10,1.20) and name (string where values can repeat). And my problem is to set it to winForms control like combobox. But I want to that user in field will see only name and id will not visible but subconsciously should be connect to names in control that when user select item in combobox I can get this id. ...

DataGridView, databinding, and ComboBox filtering

Hello, I have a DataGridView with a combobox column in it, showing the possible prices, and I would like to only display the prices relevant to the particular row. In more details, let's say that I have a class method which returns me a dataset with 2 tables populated (feeded by a stored procedure running on a SQL Server 2005 database)...

DoDragDrop() from another thread

Every time i want let the user to drag an control, i calling DoDragDrop of that control. The drag & drop works fine, but i have problem with things around: DoDragDrop completely blocking the form, no timer events jumps, no paint messages handled. DoDragDrop blocking not only for the drag & drop operation, but until target program fini...

C# - Pushing Enter in MessageBox triggers control KeyUp Event

System: Windows7 Pro, Visual Studio 2010, C# I have a textbox: textBox1 I set its event: textBox1.KeyUp += new KeyEventHandler(textBox1_KeyUp); private void textBox1_KeyUp(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { button1.PerformClick(); } } pr...

winforms designer problem on a form

I have a form that when I open it (double clicking the file in visual studio), loads the designer, shows the form control's and automatically modified the file (without doing nothing) the asterisk is appearing on the file tab, like "mainForm.cs* [Designer]". Edit: I openned and save, and after saving, y close de form, load again and the...

Windows Forms Glass Effect, Make ImageBox transparent

Hi - I have a windows form application, and I have extended the window's frame into the client area using DwmExtendFrameIntoClientArea to get the glass effect. Now I'm trying to show a transparent PNG image in a picture box, however the background shows up as white instead of the glass effect. How can i make the image show as transparen...

Windows 7 Snap - Windows Message ?

In my windows form application I want to capture the windows 7 snap message, does anyone know which message is generated when the window is about to be snapped. I tried to listen in to the application and it looks like WM_GETMINMAXINFO = 0x24; is generated. Can anyone confirm if thats really the windows message for snap? ...

Count Number of emails in gmail using IMAP

hi can anyone tell me how i can get the number o unread items in my inbox from gmail using imap or something else and display it in a label in c# win forms. i tried using atom feeds but never could get it here is a pic of what i want to do if it helps ![Inbox(1)][1] ...

How display a Model form in a position relative to the a control in the parent window (opener)

well i have a form that i open using ShowDialog(this). i try to change the position of the form using its Location property, but i dont understand this position is relative to what exactly? i want to open this form below a certain button. so how can this be done? thanks ...

Crawler, relative path to absolute path.

Hi, I am trying to fetch pages using "httpwebrequest", but the links also have relative path in them like (.../something/, ../.../something/) , i am trying to map them to absolute path, i am not too good at programming, do we have any utility helpers to do the job, any links, articles, tutorials appreciated. Thank you in advance. ...

How to get the Screen position of a control inside a group box control?

well i was PointToScreen() but when the control is inside a group box this method dont work and gives me wrong coordinates. so is there is anyother method to get the position of a control inside a group box control? i need that screen position so i can display a dialog near that control. thanks ...

dispose and ... ?

i dispose a object in my code. and i wanna now create it again. how? Answer is : private void showToolStripMenuItem_Click(object sender, EventArgs e) { xpPanelGroup1.CreateControl(); xpPanelGroup1.Visible = true; ... } private void noShowToolStripMenuItem_Click(object sender, EventArgs e) ...

Format the list items from the DataGridViewComboBox

Hello, I'm displaying prices on a DataGridView (on a WinForms application developped in C# on VS 2008). The column type is DataGridViewComboBoxColumn. The DefaultCellStyle.Format property for this column is set to "C2" and the prices are indeed formatted as currency in the cells of this column. However, when the user clicks the ComboB...