From 0368aabc1d60db0cb0e37619be194729c12fe847 Mon Sep 17 00:00:00 2001 From: Sreemon Premkumar M Date: Mon, 18 Aug 2025 16:20:19 +0530 Subject: [PATCH 1/2] ES-975464 - Resolve the ReadMe file length issue in this sample repository --- README.md | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7851c4b..0b33b53 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,69 @@ # How to set folder browser cell in winforms gridcontrol -This example demonstrates how to set folder browser cell in winforms gridcontrol + +This example demonstrates how to set folder browser cell in [WinForms GridControl](https://www.syncfusion.com/winforms-ui-controls/grid-control). + +To use the `FolderBrowser` cell type, create custom `FolderBrowserCellModel` and `FolderBrowserCellRenderer` derived from [GridTextBoxCellModel](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.Grid.GridTextBoxCellModel.html) and [GridTextBoxCellRenderer](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.Grid.GridTextBoxCellRenderer.html). The Folder Browser dialog box will be displayed in the [OnButtonClicked](https://help.syncfusion.com/cr/windowsforms/Syncfusion.Windows.Forms.Grid.GridCellRendererBase.html#Syncfusion_Windows_Forms_Grid_GridCellRendererBase_OnButtonClicked_System_Int32_System_Int32_System_Int32_) method. + +### Creating CustomCellModel + +``` c# +//Deriving GridTextBoxCellModel. +public class FolderBrowserCellModel : GridTextBoxCellModel +{ + protected FolderBrowserCellModel(SerializationInfo info, StreamingContext context) + : base(info, context) + { + //Set the button bar size. + base.ButtonBarSize = new Size(20, 20); + } + //Constructor for the Derived Class + public FolderBrowserCellModel(GridModel grid) + : base(grid) + { + + } + //Override the CreateRenderer() in the Base class. + public override GridCellRendererBase CreateRenderer(GridControlBase control) + { + //Return the Custom Renderer Object + return new FolderBrowserCellRenderer(control, this); + } +} +``` + +### Creating CustomCellRenderer + +``` c# +//Deriving the GridTextBoxCellRenderer. +public class FolderBrowserCellRenderer : GridTextBoxCellRenderer +{ + //FolderBrowser object declaration. + private System.Windows.Forms.OpenFileDialog folderBrowser1; + public FolderBrowserCellRenderer(GridControlBase grid, GridTextBoxCellModel cellModel) + : base(grid, cellModel) + { + AddButton(new BrowseButton(this)); + //Initialize the folderBrowser1 object. + this.folderBrowser1 = new System.Windows.Forms.OpenFileDialog(); + } + #region [overrides] + protected override void OnButtonClicked(int rowIndex, int colIndex, int button) + { + base.OnButtonClicked(rowIndex, colIndex, button); + if(folderBrowser1.ShowDialog()== DialogResult.OK) + { + string filePath = folderBrowser1.FileName; + } + } +} +``` + +### Adding CellModel + +``` c# +// Add the custom cell type to the CellModels of the GridControl. +this.gridControl1.CellModels.Add("FolderBrowser", new FolderBrowserCellModel(gridControl1.Model)); +// Set the cell type to "FolderBrowser" +this.gridControl1[2, 3].Text = "Browse here"; +this.gridControl1[2, 3].CellType = "FolderBrowser"; +``` \ No newline at end of file From 7b90bb4524cb798ebd2071e5d94d9ca0c083db0b Mon Sep 17 00:00:00 2001 From: SreemonPremkumarM Date: Fri, 31 Oct 2025 00:10:28 +0530 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0b33b53..ced512b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# How to set folder browser cell in winforms gridcontrol +# How to Set Folder Browser Cell Type in WinForms GridControl? This example demonstrates how to set folder browser cell in [WinForms GridControl](https://www.syncfusion.com/winforms-ui-controls/grid-control). @@ -66,4 +66,4 @@ this.gridControl1.CellModels.Add("FolderBrowser", new FolderBrowserCellModel(gri // Set the cell type to "FolderBrowser" this.gridControl1[2, 3].Text = "Browse here"; this.gridControl1[2, 3].CellType = "FolderBrowser"; -``` \ No newline at end of file +```