or

private void frmMain_Load(object sender, EventArgs e) { DataSet ds = new DataSet(); DataRelation relation; string connectionString = "server=MYSQLSERVER;database=MyStore;uid=FakeUserID;pwd=FakePassword"; SqlConnection mySqlConnection = new SqlConnection(connectionString); string strCustomer_Query = "Select * from Customer"; string strPurchases_Query = "Select * from Purchases"; try { SqlCommand sql_Customer = new SqlCommand(strCustomer_Query, mySqlConnection); SqlDataAdapter da = new SqlDataAdapter(sql_Customer); da.Fill(ds, "Customer"); da.SelectCommand.CommandText = strPurchases_Query; da.Fill(ds, "Purchases"); // Add the relation. Maybe this is not needed because we use the RelationBindings of the RadTreeView DataColumn parentCol = ds.Tables["Customer"].Columns["ID"]; DataColumn childCol = ds.Tables["Purchases"].Columns["Customer_ID"]; relation = new DataRelation("Customer_Purchases", parentCol, childCol); ds.Relations.Add(relation); treeView1.ShowLines = true; treeView1.RelationBindings.Add(new RelationBinding(ds, "CustomerName", "Customer_ID", "PurchaseID", "ID")); treeView1.DataSource = ds; treeView1.DisplayMember = "CustomerName"; treeView1.ValueMember = "ID"; treeView1.ParentMember = "ID"; treeView1.ChildMember = "PurchaseID"; treeView1.ExpandAll(); } private void InitPvProductCategoryTree()
{
ProductDAO proDao = new ProductDAO();
List<ProductCategory> categorys = proDao.GetAllCategoryList("");
tbxCategroy.DisplayMember = "CategoryName";
this.tbxCategroy.ValueMember = "ProductCategoryID";
this.tbxCategroy.ParentIDMember = "ParentID";
this.tbxCategroy.DataSource = categorys;
// this.tbxCategroy.DataMember = "Nodes";
}
private string ConvertDataToString(bool onlySelectedRows){ StringBuilder sbTextData = new StringBuilder(); // Copy columns header foreach (GridViewColumn col in this.radGridView.Columns) { sbTextData.Append(col.HeaderText.Replace("\n", " ") + "\t"); } sbTextData.Append("\n"); // Convert only selected rows if (onlySelectedRows) { foreach (GridViewRowInfo row in this.radGridView.SelectedRows) { int i = 0; while (i < row.Cells.Count) { if (i > 0) { sbTextData.Append("\t"); } if (row.Cells[i].ColumnInfo is GridViewComboBoxColumn) { // Obtain displayed data } else if (row.Cells[i].Value == null) { sbTextData.Append(string.Empty); } else { sbTextData.Append(row.Cells[i].Value.ToString()); } i++; } sbTextData.Append("\n"); } } else { foreach (GridViewRowInfo row in this.radGridView.Rows) { int i = 0; while (i < row.Cells.Count) { if (i > 0) { sbTextData.Append("\t"); } if (row.Cells[i].Value == null) { sbTextData.Append(string.Empty); } else { sbTextData.Append(row.Cells[i].Value.ToString()); } i++; } sbTextData.Append("\n"); } } return sbTextData.ToString();}
I have a hierarchic GridView and I want to scroll to the selected row after a new databind of the control.
If I do
this.radGridView1.TableElement.ScrollToRow(this.radGridView1.CurrentRow);no problem if the current row is a parent row but if the current row is a child row the GridView scroll to the end.
How to scroll to a selected child row?
Thanks