Click here to Skip to main content
15,921,840 members

Comments by Cho Lay (Top 10 by date)

Cho Lay 10-Dec-14 5:06am View    
I am now ok thanks :D
Cho Lay 10-Dec-14 4:40am View    
when i changed like that
this.vScrollBar1.Maximum = this.dgvItem.Rows.Count ;

but not ok because vScroll and DGV are fit so i can't scroll :)
Cho Lay 10-Dec-14 4:34am View    
if not I have no idea more. So please edit my code.Please help me. Thanks
Cho Lay 10-Dec-14 4:10am View    
Yes i already write code like that :
public frmItemList()
{
InitializeComponent();


this.vScrollBar1.Minimum = 0;
this.vScrollBar1.Maximum = this.dgvItem.DisplayRectangle.Height;
this.vScrollBar1.LargeChange = vScrollBar1.Maximum / vScrollBar1.Height + this.dgvItem.Height -10 ;
this.vScrollBar1.SmallChange = 30;
this.vScrollBar1.Value = Math.Abs(this.dgvItem.AutoScrollOffset.Y);

}
private void frmItem_Load(object sender, EventArgs e)
{
dgvdatabind();
this.vScrollBar1.Scroll += new System.Windows.Forms.ScrollEventHandler(vScrollBar1_Scroll);
}
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{
dgvItem.FirstDisplayedScrollingRowIndex = vScrollBar1.Value;

//if (dgvItem.FirstDisplayedScrollingRowIndex + dgvItem.DisplayedRowCount(false) < dgvItem.Rows.Count)
//{
// dgvItem.FirstDisplayedScrollingRowIndex += dgvItem.DisplayedRowCount(false);

//}
//else
//{
// dgvItem.FirstDisplayedScrollingRowIndex = dgvItem.Rows.Count - 1;
//}

}


but i get error when i scroll vScrollBar.
I don't know what wrong and what need my code :(
Cho Lay 10-Dec-14 3:04am View    
When changed my code as below
private void vScrollBar1_Scroll(object sender, ScrollEventArgs e)
{

//dgvItem.FirstDisplayedScrollingRowIndex = vScrollBar1.Value;

if (dgvItem.FirstDisplayedScrollingRowIndex + dgvItem.DisplayedRowCount(false) < dgvItem.Rows.Count)
{
dgvItem.FirstDisplayedScrollingRowIndex += dgvItem.DisplayedRowCount(false);

}
else
{
dgvItem.FirstDisplayedScrollingRowIndex = dgvItem.Rows.Count - 1;
}

}
i have not error when scroll but scroll down is ok but scroll up not load datagried view.
what need my code for scroll up. please Give me instruction and Solution.