0

Having something like such DataGridViewTextBoxColumn:

var decayTimeColumn = new DataGridViewTextBoxColumn
{
  DataPropertyName = "DecayTimeUi",
  HeaderText = @"half-life"
};

That works on top of List<T> where T has .DecayTimeUi geter returning float how to controll the way it is displayed (set its value.ToString("E", CultureInfo.InvariantCulture) instead of default ToString)?

4

1 回答 1

1

Set the format of the cell through the DefaultCellStyle:

var decayTimeColumn = new DataGridViewTextBoxColumn {
  DataPropertyName = "DecayTimeUi",
  HeaderText = @"half-life",
  DefaultCellStyle.Format = "E"
};

It only supports a string, though, so no strongly-typed culture can be specified in that way; you'd need to find a shorthand formatting string that applies to you circumstance.

于 2013-03-30T21:27:14.003 回答