private int limit = 20, maximumrowcount = 20, offset = 0;
DataTable table = new DataTable();
SqlCeDataAdapter adapter;
SqlCeConnection conn;
void Form1_Load(object sender, EventArgs e)
{
//Access the database and get the NorthWind
conn = new SqlCeConnection();
conn.ConnectionString = "Data Source = " + (@"..\..\" + "NorthwindIO_3.5.sdf");
conn.Open();
LoadData();
GridControl grid = SampleControl1.multiColumnBoundCombo.ListBox.Grid;
grid.QueryCellInfo += Grid_QueryCellInfo;
}
private void LoadData()
{
table.Clear();
adapter = new SqlCeDataAdapter("SELECT CompanyName, ContactName FROM Customers ORDER BY CompanyName", conn);
adapter.Fill(offset, maximumrowcount, table);
//Bind the Data Table with the MultiColumnBoundCombobox DataSource
this.SampleControl1.multiColumnBoundCombo.DataSource = table;
this.SampleControl1.multiColumnBoundCombo.SelectedIndex = 1;
adapter.Dispose();
conn.Close();
}
private void Grid_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
//Determine bottom of the record.
if (e.RowIndex == maximumrowcount && e.ColIndex == 0)
{
maximumrowcount += limit;
LoadData();
}
} |