Last active
September 12, 2021 09:32
-
-
Save ritacse/e6e19d0367db85deb86f7d5902aef7f6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Listbox items unchecked from another event | |
if (lstBoxOrderNo1.CheckedItems.Count > 0) | |
{ | |
int count = lstBoxOrderNo1.CheckedItems.Count; | |
for (int i = 0; i < count; i++) | |
{ | |
lstBoxOrderNo1.SetItemChecked(lstBoxOrderNo1.CheckedIndices[0], false); | |
} | |
} | |
/// Listbox items unchecked on event fire | |
private void lstBoxOrderNo1_ItemCheck(object sender, ItemCheckEventArgs e) | |
{ | |
e.NewValue = CheckState.Unchecked; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CheckBox HeaderCheckBox = null; | |
private void Load_Grid_Data(string CodeStr) | |
{ | |
try | |
{ | |
grdData = iManipulator.GetDataSet("[dbo].[proll_populate_attendance_early_out_approval_grid_sp_1] '" +CodeStr.ToString().Trim()+"','" + compCode + "','" + deptCode + "','" + sectionCode + "','" + unitCode + "','" + lineCode + "','" + desig + "','" + empList + "','" + date + "'").Tables[0].Copy(); | |
grdGroupLeave.DataSource = grdData; | |
initGroupLeaveGrid(); | |
//Adding Header checkBox for select All | |
HeaderCheckBox = new CheckBox(); | |
//Place the Header CheckBox in the Location of the Header Cell. | |
Point headerCellLocation = this.grdGroupLeave.GetCellDisplayRectangle(0, -1, true).Location; | |
HeaderCheckBox.Location = new Point(headerCellLocation.X + 8, headerCellLocation.Y + 2); | |
HeaderCheckBox.BackColor = Color.White; | |
////Assign Click event to the Header CheckBox. | |
//headerCheckBox.Click += new EventHandler(HeaderCheckBox_Clicked); | |
//Assign CheckedChanged event to the Header CheckBox. | |
HeaderCheckBox.CheckedChanged += new EventHandler(HeaderCheckBox_CheckedChanged); | |
HeaderCheckBox.Size = new Size(15, 15); | |
this.grdGroupLeave.Controls.Add(HeaderCheckBox); | |
} | |
catch (Exception errExp) | |
{ | |
MessageBox.Show(errExp.Message,Application.ProductName,MessageBoxButtons.OK,MessageBoxIcon.Error); | |
} | |
} | |
private void initGroupLeaveGrid() | |
{ | |
iDBGrid.gridInit(grdGroupLeave); | |
grdGroupLeave.Columns[0].HeaderText = ""; /// Must Empty CheckBox Header Name | |
grdGroupLeave.Columns[0].Width = 30; | |
grdGroupLeave.Columns[9].Visible = false; | |
grdGroupLeave.Columns["LcScBuyer"].Visible = false; ///with column name | |
grdGroupLeave.Columns[1].ReadOnly = true; | |
grdGroupLeave.Columns[2].Frozen = true; | |
grdLcScMapping.Columns["LcNo"].DefaultCellStyle.BackColor = Color.Wheat; | |
grdGroupLeave.Refresh(); | |
grdGroupLeave.AllowUserToDeleteRows = false; | |
} | |
//Defination of CheckedChanged event of Header CheckBox. | |
private void HeaderCheckBox_CheckedChanged(object sender, EventArgs e) | |
{ | |
try | |
{ | |
if (HeaderCheckBox.Checked) | |
{ | |
for (int i = 0; i < grdGroupLeave.Rows.Count; i++) | |
{ | |
grdGroupLeave[0, i].Value = true; /// Check all | |
} | |
} | |
else | |
{ | |
for (int i = 0; i < grdGroupLeave.Rows.Count; i++) | |
{ | |
grdGroupLeave[0, i].Value = false; /// UnCheck all | |
} | |
} | |
} | |
catch (Exception) | |
{ | |
throw; | |
} | |
} | |
private void ClearGrid() | |
{ | |
DataTable empdt = new DataTable(); | |
grdData = empdt.Copy(); | |
Load_Grid_Data(); | |
grdGroupLeave.Controls.Clear(); /// clear Header Checkbox | |
grdGroupLeave.Refresh(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment