private void loadWidthColumn() { if (grDanhSach.Items.Count > 0) { int idx = 1; foreach (HeaderDto item in lstHeader) { double width = (double)item.WidthValue; if (width > 0) { Telerik.Windows.Controls.GridViewLengthUnitType unit = new Telerik.Windows.Controls.GridViewLengthUnitType(); if (item.WidthUnit.Equals(ApplicationConstant.layGiaTri(ApplicationConstant.UnitWidth.Pixel))) { unit = Telerik.Windows.Controls.GridViewLengthUnitType.Pixel; } else if (item.WidthUnit.Equals(ApplicationConstant.layGiaTri(ApplicationConstant.UnitWidth.Star))) { unit = Telerik.Windows.Controls.GridViewLengthUnitType.Star; } else if (item.WidthUnit.Equals(ApplicationConstant.layGiaTri(ApplicationConstant.UnitWidth.Percent))) { unit = Telerik.Windows.Controls.GridViewLengthUnitType.Auto; } grDanhSach.Columns[idx].Width = new Telerik.Windows.Controls.GridViewLength(width, unit); grDanhSach.Columns[idx].IsReadOnly = true; } else { grDanhSach.Columns[idx].IsVisible = false; } idx = idx + 1; } columnsWidthLoad = true; } }
private void loadWidthColumn() { if (grvKheUoc.Columns.Count >= lstHeader.Count) { int idx = 1; foreach (HeaderDto item in lstHeader) { double width = (double)item.WidthValue; if (width > 0) { Telerik.Windows.Controls.GridViewLengthUnitType unit = new Telerik.Windows.Controls.GridViewLengthUnitType(); if (item.WidthUnit.Equals(ApplicationConstant.layGiaTri(ApplicationConstant.UnitWidth.Pixel))) { unit = Telerik.Windows.Controls.GridViewLengthUnitType.Pixel; } else if (item.WidthUnit.Equals(ApplicationConstant.layGiaTri(ApplicationConstant.UnitWidth.Star))) { unit = Telerik.Windows.Controls.GridViewLengthUnitType.Star; } else if (item.WidthUnit.Equals(ApplicationConstant.layGiaTri(ApplicationConstant.UnitWidth.Percent))) { unit = Telerik.Windows.Controls.GridViewLengthUnitType.Auto; } grvKheUoc.Columns[idx].Width = new Telerik.Windows.Controls.GridViewLength(width, unit); grvKheUoc.Columns[idx].Header = LLanguage.SearchResourceByKey(item.LanguageKey); } else { grvKheUoc.Columns[idx].IsVisible = false; } idx = idx + 1; } for (int i = idx; i < grvKheUoc.Columns.Count; i++) { grvKheUoc.Columns[i].IsVisible = false; } columnsWidthLoad = true; } }