dapfor datasource
I have a couple of questions regarding databinding. I've implemented the IListSource interface (based on the MultipleDataSources class from the tutorial part 4: order book) and want to know if it's possible to dynamically add ILists to the list.
The business case is that I'm creating data sources while my program runs and would like to add these to the grid (basically add them to the IListSource).
The second question is about a fixed column showing rownumbers. The requirement is to have a fixed column showing the rownumber (starting with 1. basically row visible index + 1). My grid is bound to a datasource (see question 1) and I was wondering if there is an easy way to implement this?
Thanks,
Michel
-
Hi,
1. IListSource doesn't have events enabling to notify the grid. Therefore you have to rebind the datasource.
2. Yes, you can display what you want in the row selector. Here is a code example:grid.RowSelector.Width = 50;
grid.PaintRow += delegate(object sender, PaintRowEventArgs e)
{
e.PaintAll();
e.Handled = true;
using (StringFormat sf = new StringFormat())
{
sf.Alignment = StringAlignment.Center;
e.Graphics.DrawString((e.Row.VisibleIndex + 1).ToString(),
e.Font,
SystemBrushes.GrayText,
e.RowSelectorBounds,
sf);
}
};Best regards,
Dapfor0
Please sign in to leave a comment.
Comments
1 comment