Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
144452 | May 7,2019 10:57 AM UTC | May 13,2019 06:15 AM UTC | WinForms | 5 |
![]() |
Tags: SfDataGrid |
GridButtonColumn column = new GridButtonColumn() { MappingName = "PDF_File", HeaderText = "PDF_File" };
this.sfDataGrid1.Columns.Add(column);
this.sfDataGrid1.CellButtonClick += sfDataGrid1_CellButtonClick;
void sfDataGrid1_CellButtonClick(object sender, CellButtonClickEventArgs e)
{
var rowData = (e.Record as Syncfusion.WinForms.DataGrid.DataRow).RowData;
string fileName = (rowData as OrderInfo).PDF_File;
/// Implement the code to open the file in button column
} |
public Form1()
{
InitializeComponent();
this.sfDataGrid1.DataSource = GetDataTable();
this.sfDataGrid1.Columns.Add(new GridNumericColumn() { MappingName = "EmployeeID", HeaderText = "EmployeeID"});
this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "EmployeeName", HeaderText = "EmployeeName" });
this.sfDataGrid1.Columns.Add(new GridTextColumn() { MappingName = "CustomerID", HeaderText = "CustomerID" });
GridButtonColumn column = new GridButtonColumn() { MappingName = "PDF_File", HeaderText = "PDF_File" };
this.sfDataGrid1.Columns.Add(column);
this.sfDataGrid1.CellButtonClick += sfDataGrid1_CellButtonClick;
this.sfDataGrid1.Columns.Add(new GridDateTimeColumn() { MappingName = "Date", HeaderText = "Order Date", FilterMode = ColumnFilter.DisplayText });
} |
void sfDataGrid1_CellButtonClick(object sender, CellButtonClickEventArgs e)
{
var rowData = (e.Record as Syncfusion.WinForms.DataGrid.DataRow).RowData as DataRowView;
string fileName = rowData["PDF_File"].ToString();
/// Implement the code to open the file in button column
//Process.Start(fileName);
} |
Thanks for the quick reply, that's what I was looking for ... Thank you for your support
here is the code I used
////////////////////////////////////////////////////////////////////////////Start Code ////////////////////////////////////////////////////////////////////////////
this.sfDataGrid1.CellButtonClick += sfDataGrid1_CellButtonClick;
sfDataGrid1.Columns.Add(new GridButtonColumn()
{
MappingName = "PDF_File",
HeaderText = "File"
});
private void sfDataGrid1_CellButtonClick(object sender, Syncfusion.WinForms.DataGrid.Events.CellButtonClickEventArgs e)
{
var rowData = (e.Record as Syncfusion.WinForms.DataGrid.DataRow).RowData as DataRowView;
string fileName = rowData["PDF_File"].ToString();
Process.Start(fileName);
}
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.