This is a migrated thread and some comments may be shown as answers.

Scrolling two grids

6 Answers 223 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 1
Dan asked on 15 Apr 2010, 03:28 PM
I have two RadGrids on the same page.  They have the same list of people in both grids, just with different information in each.  When I scroll one grid, I want to make sure that I scroll the other one to the same person.  They are the same height.  I have implemented two scroll events in the form's OnLoad:
 
this.gv1.GridElement.VScrollBar.Scroll += new ScrollEventHandler(gv1_VScrollBar_Scroll);
this.gv2.GridElement.VScrollBar.Scroll += new ScrollEventHandler(gv2_VScrollBar_Scroll);

And then I have:

void gv1_VScrollBar_Scroll(object sender, ScrollEventArgs e)

 

{

    gv2.GridElement.VScrollBar.Value = e.NewValue;

}
 

 

void gv2_VScrollBar_Scroll(object sender, ScrollEventArgs e)

{

    gv1.GridElement.VScrollBar.Value = e.NewValue;

}

 

Here's the problem.  It works for gv1.  The event never even fires for gv2.  If I comment out the functioning one, the other still doesn't work.  Off the top of my head, the only difference I can come up with is that gv2 is heirarchical.  Any thoughts?
Thanks,
Dan

6 Answers, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 16 Apr 2010, 05:31 PM
Hi Dan,

Thank you for contacting us.

The issue cannot be reproduced in a simple scenario with two RadGridViews, one of them hierarchical.

Consider the code snippet:
 
public class Data
{
    public int ID { get; set; }
    public string Info { get; set; }
}
 
public class DataRelation
{
    public int ID { get; set; }
    public string Info { get; set; }
}
 
private void BindGrids()
{
    // fill application data
    List<Data> data1 = new List<Data>();
    List<Data> data2 = new List<Data>();
    List<DataRelation> dataRelation = new List<DataRelation>();
 
    FillData(data1);
    FillData(data2);
    FillDataRelation();
 
    // bind the first grid
    radGridView1.DataSource = data1;
 
    // bind the hierarchical grid
    radGridView2.DataSource = data2;
 
    GridViewTemplate template = new GridViewTemplate();
    template.DataSource = dataRelation;
    radGridView2.MasterGridViewTemplate.ChildGridViewTemplates.Add(template);
 
    GridViewRelation relation = new GridViewRelation(radGridView2.MasterGridViewTemplate);
    relation.ChildTemplate = template;
    relation.RelationName = "Relation";
    relation.ParentColumnNames.Add("ID");
    relation.ChildColumnNames.Add("ID");
    radGridView2.Relations.Add(relation);
 
    // handlers
    radGridView1.GridElement.VScrollBar.Scroll += new ScrollEventHandler(radGridView1_VScrollBar_Scroll);
    radGridView2.GridElement.VScrollBar.Scroll += new ScrollEventHandler(radGridView2_VScrollBar_Scroll);
}
 
private void radGridView1_VScrollBar_Scroll(object sender, ScrollEventArgs e)
{
    radGridView2.GridElement.VScrollBar.Value = e.NewValue;
}
 
private void radGridView2_VScrollBar_Scroll(object sender, ScrollEventArgs e)
{
    radGridView1.GridElement.VScrollBar.Value = e.NewValue;
}

The above scenario works fine. Please provide us with more details for your case or send us a project demonstrating the issue. It will help us define the problem. I am looking forward for your reply.

Regards,
Alexander
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Dan
Top achievements
Rank 1
answered on 19 Apr 2010, 07:42 PM
Hi Alexander,
Thank you so much for looking into this.  I made a few small projects today and untill just now could only verify what you said.  It works fine.  So back to the original project.  I copied the grid with the non-firing event, pasted it back onto the very same form, attached a scroll event, and it worked fine.
Then I began moving lines of code over to the new grid.  A difference that I didn't even think to mention was that the problematic grid also had a column group view definition applied.  When I changed that line of code to the new grid, the new grid quit working.

First off, my apologies if that is a known issue and my not mentioning it cost you time.

Secondly, here is my code.  Have I done it wrong?

private void SetUpColumnGroups()
{

ColumnGroupsViewDefinition colGroups = new ColumnGroupsViewDefinition();
colGroups.ColumnGroups.Add(new GridViewColumnGroup());
colGroups.ColumnGroups.Add(new GridViewColumnGroup("Month"));
colGroups.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());
colGroups.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
colGroups.ColumnGroups[0].Rows[0].Columns.Add(gv1.Columns["Name"]); colGroups.ColumnGroups[0].Rows[0].Columns.Add(gv1.Columns["Room"]);
colGroups.ColumnGroups[0].Rows[0].Columns.Add(gv1.Columns["Area"]);
colGroups.ColumnGroups[0].Rows[0].Columns.Add(gv1.Columns["WValue"]);

for (int i = 1; i <= 5; i++)
{
colGroups.ColumnGroups[1].Rows[0].Columns.Add(gv1.Columns[string.Format("Week{0}Date", i.ToString())]);
colGroups.ColumnGroups[1].Rows[0].Columns.Add(gv1.Columns[string.Format("Week{0}Code1", i.ToString())]);
colGroups.ColumnGroups[1].Rows[0].Columns.Add(gv1.Columns[string.Format("Week{0}Code2", i.ToString())]);
colGroups.ColumnGroups[1].Rows[0].Columns.Add(gv1.Columns[string.Format("Week{0}Value", i.ToString())]);
}

gv1.ViewDefinition = colGroups;  //When I comment out this line, scolling works
gv1.MasterGridViewTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
}


Thank you for your time,
Dan

 

 

 

 

 

 

0
Alexander
Telerik team
answered on 21 Apr 2010, 02:29 PM
Hello Dan,

I am sorry but we still cannot reproduce the bug using your SetUpColumnGroups() method and populating the RadGridView with sample data.

It would be best if you can reproduce the issue in a simple project. If not, please send us your project in a new support ticket so we can debug it and find the issue. I am waiting for your response.
 

Regards,
Alexander
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Praveena
Top achievements
Rank 1
answered on 24 Nov 2011, 01:01 PM
Hi Alexander,

           I also faced the same type of issue. And resolved it very easily with the help of your post. Thanks a lot!! It is really helpful and saved my time.

Regards,
Praveena
0
Avinash
Top achievements
Rank 1
answered on 16 Apr 2012, 02:28 AM
hi Telerik team,

I am using Telerik winforms 2010 Q3 RadGridView Control.
I am having issue in implementing Vertical scrolling when i use
ColumnGroupsViewDefinition as ViewDefinition.
I tried on the forums also but couldn't find any suitable solution.

My code is:
ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();         
    view.ColumnGroups.Add(new GridViewColumnGroup(""));
    view.ColumnGroups.Add(new GridViewColumnGroup("Target Category"));   
    view.ColumnGroups.Add(new GridViewColumnGroup("Source Category"));
    view.ColumnGroups[0].Rows.Add(new GridViewColumnGroupRow());  
    view.ColumnGroups[0].Rows[0].Columns.Add(radGridView.Columns["Column1"]);
    view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[1].Rows[0].Columns.Add(radGridView.Columns["Column11"]);
   view.ColumnGroups[1].Rows[0].Columns.Add(radGridView.Columns["column12]);
    view.ColumnGroups[2].Rows.Add(new GridViewColumnGroupRow());
    view.ColumnGroups[2].Rows[0].Columns.Add(radGridView.Columns["column21"]);
    view.ColumnGroups[2].Rows[0].Columns.Add(radGridView.Columns["column22"]);
    this.radGridView.ViewDefinition = view;


When I use ViewDefinition I am not able to get vertical scrolling for the view.

Please let me know how can I achieve this.
Waiting for your reply.
thanks,
Avinash

0
Svett
Telerik team
answered on 18 Apr 2012, 02:47 PM
Hello Avinash,

I am not able to assist you efficiently with the supplied information. I would kindly ask you to open a support ticket where you can attach a sample project that demonstrates your scenario in depth, so we can investigate it and provide you with adequate support.

Greetings,
Svett
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Dan
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Dan
Top achievements
Rank 1
Praveena
Top achievements
Rank 1
Avinash
Top achievements
Rank 1
Svett
Telerik team
Share this question
or