After some considerable searching I havent been able to find a solution to this issue. I have successfully set the datasource of a DatagridView using a list as follows.
The class
public class ChannelInfo
{
[Browsable(false)]
[DisplayName("ChannelId")]
public int channelId { get; set; }
[DisplayName("Channel")]
public string sysName { get; set; }
[DisplayName("Display Name")]
public string dispName { get; set; }
[DisplayName("Unit")]
public string unit { get; set; }
[DisplayName("Divide By")]
public int divideBy { get; set; }
[DisplayName("YAxis")]
public string yAxis { get; set; }
[DisplayName("Min Scale")]
public int scaleMin { get; set; }
[DisplayName("Max Scale")]
public int scaleMax { get; set; }
[DisplayName("Colour")]
public string colour { get; set; }
[DisplayName("Set Point")]
public double setPoint { get; set; }
[DisplayName("Limit(+/-)")]
public double? limit { get; set; }
[DisplayName("MKT")]
public bool? IncludeInMKT { get; set; }
/// <summary>
/// Default constructor
/// </summary>
public ChannelInfo()
{
}
/// <summary>
/// Copy constructor to create a copy of another object
/// </summary>
/// <param name="ci"> and object of the type ChannelInfo whos copy is to be created</param>
public ChannelInfo(ChannelInfo ci)
{
channelId = ci.channelId;
sysName = ci.sysName;
dispName = ci.dispName;
unit = ci.unit;
divideBy = ci.divideBy;
yAxis = ci.yAxis;
scaleMin = ci.scaleMin;
scaleMax = ci.scaleMax;
colour = ci.colour;
setPoint = ci.setPoint;
limit = ci.limit;
IncludeInMKT = ci.IncludeInMKT;
}
}
setting the data-source of the grid
static List<ChannelInfo> chInfoList;
dgvChannels.DataSource = chInfoList;
The type of the final column of the data-grid is set to DataGridViewCheckBoxColumn using the designer. The data-grid displays all the data fine except the last boolean field IncludeInMkt. It shows the text values (True/False) whereas, I expect it to be shown as a check box with the corresponding values in the chInfoList. I have also set the TrueValue to True and FalseValue to False in the designer.
Where am I going wrong, kindly suggest.
Aucun commentaire:
Enregistrer un commentaire