winforms

How to update my database when datagrid delete some rows ?

i binding datasource in my datagrid when i remove some rows in datagrid my database not update how? ...

How to Detect Right Click on the Taskbar

I've got a Windows Forms application in C# that starts off with a loading dialog. As expected, a button for the app shows up in the Windows taskbar. I would like to detect right-clicks that might be done to that button. Ultimately, I hope to disable the right-click or simply have the loading dialog regain focus. I've seen that some p...

Task manager close is not detected second time in a WinForms Application

private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { if (MessageBox.Show(this, "Do you really want to close?", "Close?", MessageBoxButtons.YesNo) == DialogResult.No) { e.Cancel = true; } } } So...

Get aspect ratio of a monitor

I want to get aspect ratio of a monitor as two digits : width and height. For example 4 and 3, 5 and 4, 16 and 9. I wrote some code for that task. Maybe it is any easier way to do that ? For example, some library function =\ /// <summary> /// Aspect ratio. /// </summary> public struct AspectRatio { int _height; /// <summary> ...

Accessing non-static combbox property in the static method.

I have one combobox on the window form and I have one method which is declared with static like private static DataTable ParseTable(HtmlNode table) Now I want to use combobox in that method for using combobox property but I can not access any property of combobox or combobox itself.If I made the combobox declaration as static then it can...

Using Application Settings and reading defaults from app.config

Hi, I need to deploy a Windows Forms application using ClickOnce deployment. (VS2008, .NET 3.5) And I need to provide a configuration file for this app that any user can modify. For this reason, I am using Application Settings instead of standard appSetttings in app.config so I can separate the the user config from app config. see http:...

how to quickly create dummy image directly in .NET code

How to quickly create some random image with the icon size? I don't want to use neither Image.FromFile, nor Image.FromStream ...

Get the corresponding row in the datatable from the selection in datagridview

Hi All, I have a DataTable which is bound to datagridview (Winforms)... I use the following two lines to get the DataRow that is selected in the datagridview... int l_intSelectedRow = DataGridView1.SelectedRows[0].Index; DataRow l_drwSelectedRow = ControlGroupPostedItems.Tables["PostedItems"].Rows[l_intSelectedRow]; ...

Locked DataGridView. Linq is a problem ?

Hi, I get the collection from webservice: var allPlaceHolders = from ph in new MyService().GetPlaceHolders() select new { Code = ph.Code, Name = ph.Name, Related = false }; dgPlaceHoldersAdd.DataSource = allPlaceHolders.ToList(); Designer.cs: this.dgPlaceHoldersAdd.ColumnHeadersHeightSizeMode = System.Windows.Forms.Da...

Double buffering with C# has negative effect

I have written the following simple program, which draws lines on the screen every 100 milliseconds (triggered by timer1). I noticed that the drawing flickers a bit (that is, the window is not always completely blue, but some gray shines through). So my idea was to use double-buffering. But when I did that, it made things even worse. Now...

how to find all application/Thread running in a process in windows application in c# ?

Hello All, i want to get list of all application or Threads attached with a process.For example when we open different window all run with explorer.exe or we open different window of mozila all are in firefox.exe. i have to check that if a window is all ready open no need to open this.and if it is in background or minimized then then ac...

String matching.

How to match the string "Net        Amount" (between Net and Amount there can be any number of spaces, including zero) with net amount? Spaces between these two words can be any whitespace and exact matching of two string should be there. But Net Amount (first string with spaces) can be part of any string like Rate Net Amount or Rate Co...

Change TreeNode image on expand-collapse events

I have a treeView with many nodes. I want that some nodes change their image when node collapsed/expanded. How can I do it ? Unfortunately, TreeNode don't have properties like ExpandNodeImage, CollapseNodeImage \ TreeView can change very often, so nodes can be deleted/added.. i can delete child nodes and so on... Maybe, there is a...

C# listview clickable column and row

What I have going on is a listview inside of my windows form. How can I make so that only when you double click a row it pulls data for row X and column 3. meaning I have a listview of... A|B|C|D 1|2|3|4 @|#|$|% Bc|Dv|D#|dg so if i double clicked row thats begins with @ it will read in column 3 ($). I aleady have FullRowSelect = T...

C# tabcontrol border controls

Is it possible to make a tabcontrol border transparent, or to set the color of a tabcontrol? Winforms ...

C# combobox select new item.

Is it possible to set the selected item of a combobox to be an object that is not in its dropdown list? If yes, then what must one do? ...

Custom links in RichTextBox

Suppose I want every word starting with a # to generate an event on double click. For this I have implemented the following test code: private bool IsChannel(Point position, out int start, out int end) { if (richTextBox1.Text.Length == 0) { start = end = -1; return false; } int index = richTextBox1.GetCh...

How can I bind a winforms Opacity to a TrackBar (slider)

I've got a winform with a BindingSource that has an int property named Opacity in its DataSource. I also have a TrackBar on the winform that I want to use to control the Opacity of the winform. I've bound the Value property on the TrackBar to the Opacity and that functions just fine, sliding the TrackBar will change the variable from ...

LINQ2SQL - Binding result to a grid - want changes to be reflected without re-binding?

Hello, I have a grid (DevExpress XtraGrid, if that matters) which is bound to a LINQ to SQL Entity property. gridItems.DataSource = purchaseOrder.PendingItemsGrouped; Well, the grid is being displayed properly,and I can see the purchase items that are pending. The problem arises when purchaseOrder.PendingItemsGrouped gets changed ......

When I renamed a class I am getting a deserialization error. How to fix it?

I renamed the class classBattle to Game and not I get "Unable to load type battle.classBattle+udtCartesian required for deserialization." This is the line of code MapSize = (Game.udtCartesian)formatter.Deserialize(fs); How do I fix this? Does this mean I cannot rename classes? ...