Skip to main content

Posts

Showing posts from February, 2009

Register a service written by .NET

Using Visual Studio Command Prompt In command prompt windows: Register: installutil YourServiceNameWithFullPath Unregister: installutil YourServiceNameWithFullPath /u For example, I created a service named MyService.exe and put in the folder D:\Projects\Services Register: installutil D:\Projects\Services\MyService.exe Unregister: installutil D:\Projects\Services\MyService.exe /u

How to add select all checkbox to DataGridView

//Your DataGridView: dtgrd //Flag to determine select all or not bool bSelectAll = false; if (dtgrd.Controls.Find("chkSelectAll", true).Length > 0) { dtgrd.Controls.RemoveByKey("chkSelectAll"); } if (dtgrd.Rows.Count > 0) { DataGridViewCheckBoxColumn dtChkCol = new DataGridViewCheckBoxColumn(false); dtChkCol.Width = 30; dtChkCol.Resizable = DataGridViewTriState.False; dtChkCol.ReadOnly = false; dtgrd.Columns.Insert(0, dtChkCol); Rectangle rect = dtgrd.GetCellDisplayRectangle(0, -1, true); rect.X = rect.Location.X + (rect.Width / 3); rect.Y = rect.Location.Y + (rect.Height / 3); CheckBox chkSelectAll = new CheckBox(); chkSelectAll.Name = "chkSelectAll"; chkSelectAll.Size = new Size(18, 18); chkSelectAll.Location = rect.Location; chkSelectAll.CheckedChanged += new EventHandler(chkSelectAll_CheckedChanged); chkSelectAll.Checked = false; dtgrd.Controls.Add(chkSelectAll); dtgrd.Columns[lcCheck].Frozen = true; } //Event here private void c...