Completed
Last Updated: 20 Feb 2014 15:12 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 08 Oct 2013 01:47
Category: GridView
Type: Bug Report
2
FIX. RadGridView with Office2010Black does not paint its vertical scroll bar correctly
To reproduce:
-add RadGridView and RadButton to the form;
-apply Office2010Black to the grid;
-use the following code:


private DataTable dataTable; 

public Form1() 
{ 
	InitializeComponent(); 

	radGridView1.AutoSizeRows = false; 
	radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill; 
	radGridView1.RowFormatting += radGridView1_RowFormatting; 
	radGridView1.ReadOnly = true; 
	radGridView1.ShowRowHeaderColumn = false; 
	radGridView1.VerticalScrollState = ScrollState.AlwaysShow; 
	radGridView1.ThemeName = "Office2010Black"; 
	dataTable = new DataTable(); 
	dataTable.Columns.Add("number", typeof(int)); 
	dataTable.Columns.Add("descriptions", typeof(string)); 
	radGridView1.DataSource = dataTable; 
} 

void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e) 
{ 
	e.RowElement.RowInfo.Height = 120; 
} 

private void radButton1_Click(object sender, EventArgs e) 
	 { 
		 radGridView1.Enabled = false; 
		 Random rnd = new Random((int)DateTime.Now.Ticks); 
		 dataTable.Clear(); 

		 for (int i = 0; i < rnd.Next(1000); i++) 
		 { 
			 DataRow row = dataTable.NewRow(); 
			 row[0] = i + 1; 
			 row[1] = "description" + i.ToString(); 
			 dataTable.Rows.Add(row); 
		 } 
		 radGridView1.Enabled = true; 
	 } 

After clicking the button, notice that the vertical scroll bar is not painted correctly and it is resized when scrolling.

Workaround:
Update the button Click event as follows:
private void radButton1_Click(object sender, EventArgs e)
{
    radGridView1.VerticalScrollState = ScrollState.AlwaysHide;
    radGridView1.Enabled = false;
    radGridView1.BeginEdit();

    Random rnd = new Random((int)DateTime.Now.Ticks);
    dataTable.Clear();
    for (int i = 0; i < rnd.Next(1000); i++)
    {
        DataRow row = dataTable.NewRow();
        row[0] = i + 1;
        row[1] = "description" + i.ToString();
        dataTable.Rows.Add(row);
    }
    
    radGridView1.EndEdit();
    radGridView1.Enabled = true;
    radGridView1.VerticalScrollState = ScrollState.AlwaysShow; 
    radGridView1.TableElement.VScrollBar.ResetLayout(true);
    radGridView1.MasterTemplate.Refresh();
    radGridView1.TableElement.ScrollToRow(radGridView1.CurrentRow);
}
0 comments