Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143561 | Mar 26,2019 08:16 PM UTC | Mar 27,2019 12:52 PM UTC | WinForms | 1 |
![]() |
Tags: SfDataGrid |
//Set the Horizontal Alignment of the column in constructor or form load.
this.sfDataGrid1.Columns["Open"].CellStyle.HorizontalAlignment = HorizontalAlignment.Center;
this.sfDataGrid1.Columns["Map"].CellStyle.HorizontalAlignment = HorizontalAlignment.Center;
void sfDataGrid1_QueryButtonCellStyle(object sender, QueryButtonCellStyleEventArgs e)
{
//Finds the column with
if (e.Column.MappingName.Equals("Open"))
{
//if the project exists then have an open icon else have a different icon
if (Directory.Exists(projectFolderPath))
{
e.Button.Image = Properties.Resources.open.ToBitmap();
e.Button.ImageSize = new System.Drawing.Size(w, h);
}
else
{
e.Button.Image = Properties.Resources.failedopen.ToBitmap();
e.Button.ImageSize = new System.Drawing.Size(w, h);
}
}
//Another button with another icon
if (e.Column.MappingName.Equals("Map"))
{
var w = Properties.Resources.edit.Width / 4;
var h = Properties.Resources.edit.Height / 4;
e.Button.Image = Properties.Resources.map.ToBitmap();
e.Button.ImageSize = new System.Drawing.Size(w, h);
}
}
|
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.