/// <summary> /// Sự kiện chọn menu Options để cấu hình ẩn hiện cột của GridView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _Onclick(object sender, EventArgs e) { ToolStripItem Source = (ToolStripItem)sender; ContextMenuStrip Ctx = (ContextMenuStrip)Source.Owner; DataGridView _grd = (DataGridView)Ctx.SourceControl; CurrentDataGridViewName = _grd.Name; GridOptions _grdOptions = new GridOptions(GetAllColumnsOfGridView(_grd), _arrCol); if (ArrCodan.Contains(CurrentDataGridViewName)) { Codan = Convert.ToInt16(ArrCodan[CurrentDataGridViewName]); } if (ArrAlignment.Contains(CurrentDataGridViewName)) { Alignment = Convert.ToInt32(ArrAlignment[CurrentDataGridViewName]); } if (ArrGridColWidth.Contains(CurrentDataGridViewName)) { OriginalWidthOfGridColumns = ArrGridColWidth[CurrentDataGridViewName].ToString(); } if (_grd.GetContainerControl().GetType().FullName.Equals(new Form().GetType().FullName) || _grd.GetContainerControl().GetType().BaseType.BaseType.FullName.Equals(new Form().GetType().FullName)) { Form f = _grd.GetContainerControl() as Form; f.Opacity = 0.2; } _grdOptions.Codan = Codan; _grdOptions.Alignment = Alignment; _grdOptions.ShowDialog(); if (_grd.GetContainerControl().GetType().FullName.Equals(new Form().GetType().FullName) || _grd.GetContainerControl().GetType().BaseType.BaseType.FullName.Equals(new Form().GetType().FullName)) { Form f = _grd.GetContainerControl() as Form; f.Opacity = 1; } if (!_grdOptions._Cancel) { Alignment = _grdOptions.Alignment; Codan = _grdOptions.Codan; if (!ArrCodan.Contains(CurrentDataGridViewName)) { ArrCodan.Add(CurrentDataGridViewName, Codan); } else { ArrCodan[CurrentDataGridViewName] = Codan; } if (!ArrAlignment.Contains(CurrentDataGridViewName)) { ArrAlignment.Add(CurrentDataGridViewName, Alignment); } else { ArrAlignment[CurrentDataGridViewName] = Alignment; } string ArrColName = FromArrayListToStringValue(_grdOptions.InvisibleCols); SaveOptions(_Container.Name, _grd.Name, ArrColName, _grdOptions.Alignment, _grdOptions.Codan, OriginalWidthOfGridColumns); StartUpGrid(_grd); } }
/// <summary> /// Sự kiện chọn menu Options để cấu hình ẩn hiện cột của GridView /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _Onclick(object sender, EventArgs e) { ToolStripItem Source = (ToolStripItem)sender; ContextMenuStrip Ctx =(ContextMenuStrip) Source.Owner; DataGridView _grd = (DataGridView)Ctx.SourceControl; CurrentDataGridViewName = _grd.Name; GridOptions _grdOptions = new GridOptions(GetAllColumnsOfGridView(_grd),_arrCol); if (ArrCodan.Contains(CurrentDataGridViewName)) Codan = Convert.ToInt16(ArrCodan[CurrentDataGridViewName]); if (ArrAlignment.Contains(CurrentDataGridViewName)) Alignment =Convert.ToInt32( ArrAlignment[CurrentDataGridViewName]); if (ArrGridColWidth.Contains(CurrentDataGridViewName)) OriginalWidthOfGridColumns = ArrGridColWidth[CurrentDataGridViewName].ToString(); if (_grd.GetContainerControl().GetType().FullName.Equals(new Form().GetType().FullName) || _grd.GetContainerControl().GetType().BaseType.BaseType.FullName.Equals(new Form().GetType().FullName)) { Form f = _grd.GetContainerControl() as Form; f.Opacity = 0.2; } _grdOptions.Codan = Codan; _grdOptions.Alignment = Alignment; _grdOptions.ShowDialog(); if (_grd.GetContainerControl().GetType().FullName.Equals(new Form().GetType().FullName) || _grd.GetContainerControl().GetType().BaseType.BaseType.FullName.Equals(new Form().GetType().FullName)) { Form f = _grd.GetContainerControl() as Form; f.Opacity = 1; } if (!_grdOptions._Cancel) { Alignment = _grdOptions.Alignment; Codan = _grdOptions.Codan; if (!ArrCodan.Contains(CurrentDataGridViewName)) ArrCodan.Add(CurrentDataGridViewName, Codan); else ArrCodan[CurrentDataGridViewName] = Codan; if (!ArrAlignment.Contains(CurrentDataGridViewName)) ArrAlignment.Add(CurrentDataGridViewName, Alignment); else ArrAlignment[CurrentDataGridViewName] = Alignment; string ArrColName = FromArrayListToStringValue(_grdOptions.InvisibleCols); SaveOptions(_Container.Name, _grd.Name, ArrColName,_grdOptions.Alignment, _grdOptions.Codan,OriginalWidthOfGridColumns); StartUpGrid(_grd); } }