hi,
Im binding the grid to a business object witch contain a list of other object (like defined in the code below)
Im currently updating the list of sub objects and their properties and call the grid DataBind in order to update the display
but the grid dose not update the display and even dose not call the InitializeRow event
the only "ugly" way i found to refresh the display is by calling the code as i wrote in button2_Click handler below
the problem with this way to refresh the grid is that all the expended nodes will collapse
is this a problem in DataBind method or am i doin somthing wrong?
this is a simple tester i wrote to recreate the problem.
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;
namespace TestBind{ public partial class Form1 : Form { private List<Moo> moos;
public Form1() { InitializeComponent(); }
private void Form1_Load(object sender, EventArgs e) { moos = new List<Moo>(); moos.Add(new Moo("yoyoyo"));
mooBindingSource.DataSource = moos; }
private void button1_Click(object sender, EventArgs e) { moos[0].Moos.Add(new SubMoo("asdasd"));
ultraGrid1.DataBind(); }
private void button2_Click(object sender, EventArgs e) { mooBindingSource.DataSource = typeof(Moo); ultraGrid1.DataBind(); mooBindingSource.DataSource = moos; ultraGrid1.DataBind(); } }
public class Moo { private List<SubMoo> moos; private string name;
public Moo(string name) { this.name = name; moos = new List<SubMoo>(); }
public string Name { get { return name; } }
public List<SubMoo> Moos { get { return moos; } } }
public class SubMoo { private string name;
public SubMoo(string name) { this.name = name; }
public string Name { get { return name; } } }}
thanks, moshe
The DataBind method of the grid is pretty redundant. If you set the DataSource property, it implicitly binds, so there is really never any reason to use the DataBind method.
If you modify the data source and your data source does not notify the grid of the change, then you should call the grid.Rows.Refresh(ReloadData) method to update the grid.
Thank you very mutch its workin fine now
note that i needed to use the Refresh methods with recursive = True inorder to refresh the child rows
and allso i needed to call the Refresh method twise
Refresh(ReloadData, true) - to read the data again from the DataSource
Refresh(FireInitializeRow) - inorder to make the grid call the initialize row again since i had code there witch do some work
and calling with ReloadData dose not cause the Grid to call the initialize row for some reason