问题描述
private static List< datatable> SplitTable(DataTable originalTable,int batchSize)
{
List< datatable> tables = new List< datatable>();
int i = 0;
int j = 1;
DataTable newDt = originalTable.Clone ();
newDt.TableName =Table_+ j;
newDt.Clear();
foreach(原始表格中的DataRow行。行)
{
DataRow newRow = newDt.NewRow();
newRow.ItemArray = row.ItemArray;
newDt.Rows.Add(newRow);
i ++;
if(i == batchSize)
{
tables.Add(newDt);
j ++;
newDt = originalTable.Clone();
newDt.TableName =Table_ + j;
newDt.Clear();
i = 0;
}
}
{
// MouseButton mb =(MouseButton)e.OriginalSource;
// ScrollViewer sv =( ScrollViewer)e.OriginalSource;
if ((SampleDatagrid.ScrollInfo.VerticalOffset)> 400 ) // commencted
// Double d = e。(SampleDatagrid);
if (((SampleDatagrid.Records.Count / 4 )* 3 )< SampleDatagrid.ScrollInfo.VerticalOffset) // commenct ed
{
SampleDatagrid.DataSource = SystemDataHelpers.RowList(dt, 0 ,300 + Convert.ToInt32(SampleDatagrid.ScrollInfo。 VerticalOffset));
Scrollcount = Scrollcount + 1 ;
scrollsize = scrollsize + 500 ;
fillDatagrid(ldtdt);
// SampleDatagrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
// SplitTable(dt,size);
}
}
i使用Infragistics控件
{
if ((SampleDatagrid.ScrollInfo.VerticalOffset) > 400 ) // commencted
// Double d = e。(SampleDatagrid);
if (((SampleDatagrid.Records.Count / 4 )* 3 )< SampleDatagrid.ScrollInfo.VerticalOffset) // commencted
{
SampleDatagrid.DataSource = SystemDataHelpers.RowList(dt, 0 ,300 + Convert.ToInt32(SampleDatagrid.ScrollInfo) .VerticalOffset));
Scrollcount = Scrollcount + 1 ;
scrollsize = scrollsize + 500 ;
fillDatagrid(ldtdt);
}
}
SampleDatagrid.DataSource = dt.DefaultView;
我有解决方案,但是当我加载数据时我的Scroll正在上升
但我想要我的滚动应该只留在那里
private static List<datatable> SplitTable(DataTable originalTable, int batchSize)
{
List<datatable> tables = new List<datatable>();
int i = 0;
int j = 1;
DataTable newDt = originalTable.Clone();
newDt.TableName = "Table_" + j;
newDt.Clear();
foreach (DataRow row in originalTable.Rows)
{
DataRow newRow = newDt.NewRow();
newRow.ItemArray = row.ItemArray;
newDt.Rows.Add(newRow);
i++;
if (i == batchSize)
{
tables.Add(newDt);
j++;
newDt = originalTable.Clone();
newDt.TableName = "Table_" + j;
newDt.Clear();
i = 0;
}
}
{ //MouseButton mb = (MouseButton)e.OriginalSource; //ScrollViewer sv = (ScrollViewer)e.OriginalSource; if ((SampleDatagrid.ScrollInfo.VerticalOffset) > 400) //commencted //Double d=e.(SampleDatagrid); if (((SampleDatagrid.Records.Count / 4) * 3) < SampleDatagrid.ScrollInfo.VerticalOffset) //commencted { SampleDatagrid.DataSource = SystemDataHelpers.RowList(dt, 0, 300+Convert.ToInt32(SampleDatagrid.ScrollInfo.VerticalOffset)); Scrollcount = Scrollcount + 1; scrollsize = scrollsize + 500; fillDatagrid(ldtdt); //SampleDatagrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; //SplitTable(dt, size); } }
i am using Infragistics controls
{ if ((SampleDatagrid.ScrollInfo.VerticalOffset) > 400) //commencted //Double d=e.(SampleDatagrid); if (((SampleDatagrid.Records.Count / 4) * 3) < SampleDatagrid.ScrollInfo.VerticalOffset) //commencted { SampleDatagrid.DataSource = SystemDataHelpers.RowList(dt, 0, 300+Convert.ToInt32(SampleDatagrid.ScrollInfo.VerticalOffset)); Scrollcount = Scrollcount + 1; scrollsize = scrollsize + 500; fillDatagrid(ldtdt); } }
SampleDatagrid.DataSource = dt.DefaultView;
I got Solution but my Scroll is going top when i load data
but i want to My scroll should stay there only
这篇关于如何逐行向下滚动时如何从DataTable向DataGrid加载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!