Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- #region FORMATTER
- class AddSecs : IFormatProvider, ICustomFormatter
- {
- public object GetFormat(Type formatType)
- {
- if (formatType == typeof(ICustomFormatter))
- return this;
- else
- return null;
- }
- public string Format(string format, object arg, IFormatProvider formatProvider)
- {
- if (arg is int)
- {
- return arg.ToString() + " SECS";
- }
- else
- throw new ArgumentException();
- }
- }
- #endregion
- public Form1()
- {
- InitializeComponent();
- this.ultraGrid1.InitializeLayout += new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler(ultraGrid1_InitializeLayout);
- }
- protected override void OnShown(EventArgs e)
- {
- base.OnShown(e);
- // fill the grid
- Random rand = new Random();
- DataTable dt = new DataTable();
- dt.Columns.Add("COLUMN_A", typeof(int));
- for (int i = 0; i < 20; i++)
- dt.Rows.Add(rand.Next(1, 100));
- dt.AcceptChanges();
- BindingSource src = new BindingSource(dt, null);
- this.ultraGrid1.DataSource = src;
- }
- void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
- {
- e.Layout.Bands[0].Columns[0].Format = "####";
- e.Layout.Bands[0].Columns[0].FormatInfo = new AddSecs();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement