public Form1() { InitializeComponent(); var data = new EmployeeCollection(); sfDataGrid.DataSource = data.EmployeeDetails; sfDataGrid.QueryImageCellStyle += SfDataGrid_QueryImageCellStyle; sfDataGrid.QueryCellStyle += SfDataGrid_QueryCellStyle; }
public Form1() { InitializeComponent(); // Register the custom cell renderer. this.sfDataGrid.CellRenderers.Add("Rating", new GridRatingCellRenderer(new GridRatingControl(), this.sfDataGrid)); var data = new EmployeeCollection(); sfDataGrid.DataSource = data.EmployeeDetails; NumberFormatInfo numberFormat = Application.CurrentCulture.NumberFormat.Clone() as NumberFormatInfo; numberFormat.CurrencyDecimalDigits = 0; numberFormat.CurrencyGroupSizes = new int[] { }; numberFormat = Application.CurrentCulture.NumberFormat.Clone() as NumberFormatInfo; numberFormat.NumberDecimalDigits = 0; numberFormat.NumberGroupSizes = new int[] { }; this.sfDataGrid.Columns.Add(new GridCheckBoxColumn { MappingName = "Selected", HeaderText = "", AllowCheckBoxOnHeader = true, AllowFiltering = false, CheckBoxSize = new Size(14, 14) }); this.sfDataGrid.Columns.Add(new GridImageColumn() { MappingName = "EmployeeName", HeaderText = "Employee Name", ImageLayout = ImageLayout.None }); this.sfDataGrid.Columns.Add(new GridTextColumn() { MappingName = "Designation", HeaderText = "Designation" }); this.sfDataGrid.Columns.Add(new GridTextColumn() { MappingName = "Mail", HeaderText = "Mail" }); this.sfDataGrid.Columns.Add(new GridImageColumn() { MappingName = "Location", TextImageRelation = TextImageRelation.ImageBeforeText, Width = 100 }); this.sfDataGrid.Columns.Add(new GridTextColumn { MappingName = "Status", HeaderText = "Status" }); this.sfDataGrid.Columns.Add(new GridImageColumn() { MappingName = "Trustworthiness", HeaderText = "Trustworthiness" }); this.sfDataGrid.Columns.Add(new GridRatingColumn() { MappingName = "Rating", Width = 140, AllowFiltering = false, AllowSorting = false }); this.sfDataGrid.Columns.Add(new GridNumericColumn { MappingName = "Salary", HeaderText = "Salary", FormatMode = FormatMode.Currency, NumberFormatInfo = numberFormat }); this.sfDataGrid.Columns.Add(new GridTextColumn() { MappingName = "Address", HeaderText = "Address" }); this.sfDataGrid.Columns.Add(new GridProgressBarColumn() { MappingName = "SoftwareProficiency", HeaderText = "Software Proficiency", Maximum = 100, Minimum = 0, ValueMode = ProgressBarValueMode.Percentage }); this.sfDataGrid.Style.ProgressBarStyle.TextColor = Color.Black; this.sfDataGrid.Style.ProgressBarStyle.ForegroundColor = Color.CadetBlue; sfDataGrid.QueryImageCellStyle += SfDataGrid_QueryImageCellStyle; sfDataGrid.QueryCellStyle += SfDataGrid_QueryCellStyle; //Initialize CustomSelectionController. this.sfDataGrid.SelectionController = new CustomSelectionController(this.sfDataGrid); }