I am trying to have a table (a DevExpress GridControl in particular) be bound to a SortedList. I want the first column of the table to be bound to the Key of the SortedList and the second column to be bound to a field of the object in the key of the SortedList, for example,
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeTable();
}
public void InitializeTable()
{
SortedList<DateTime, Dividend> EquityDividends = new SortedList<DateTime, Dividend>();
EquityDividends.Add(new DateTime(2011, 1, 12, 16, 30, 00, DateTimeKind.Local), new Dividend(new DateTime(2011, 1, 12, 16, 30, 00, DateTimeKind.Local), "120", 12, new TimeSpan(4, 0, 0)));
EquityDividends.Add(new DateTime(2011, 1, 13, 16, 30, 00, DateTimeKind.Local), new Dividend(new DateTime(2011, 1, 12, 16, 30, 00, DateTimeKind.Local), "125", 12, new TimeSpan(4, 0, 0)));
gridControl1.DataSource = new BindingSource() { DataSource = EquityDividends };
bandedGridView1.Columns[1].FieldName = "ExpectedDividend";
}
}
public class Dividend
{
public DateTime InDividendDate;
public string ExpectedDividend;
public double Adjustment;
public TimeSpan TimeRemaining;
public Dividend(
DateTime InDividendDate,
string ExpectedDividend,
double Adjustment,
TimeSpan TimeRemaining)
{
this.InDividendDate = InDividendDate;
this.ExpectedDividend = ExpectedDividend;
this.Adjustment = Adjustment;
this.TimeRemaining = TimeRemaining;
}
}
This doesn t quite work (the key comes up in column 0 and a string "WindowsFormsApplication10.Dividend" comes up in column 1). Does anyone have any suggestions?