My problem:
I have a DataSet with 2 tables Parent and Child.
I display each table in a DataGrid.
I want to display the Parent table and give the user a choice to make changes to a few columns based on my TableStyle. However I do not want the user to add new rows to the DataGrid.
I have use this function in the past to hide the last row:
CurrencyManager cm = (CurrencyManager)BindingContext[dgParent.DataSource, dgParent.DataMember];
dv = Common.DataGrid_HideRow(dgParent, cm);
/// <summary>
/// Hides the last row on a DataGrid
/// </summary>
/// <param name="datagrid">DataGrid</param>
/// <param name="cm">CurrencyManager with the binding context</param>
public static void DataGrid_HideRow(DataGrid dg, CurrencyManager cm)
{
DataView dv = new DataView();
dv = (DataView) cm.List;
dv.AllowNew = false;
//dv.AllowEdit = true;
dg.DataSource = dv;
}
However when I do this. I do not see the child records properly. I only see the first Child record.
Here is my DataBinding code:
dgParent.SetDataBinding(DataSet1, "ParentTable");
dgChild.SetDataBinding(DataSet1, "ParentTable.ParentToChild");
Any help or advice will be great.
Thanks,
rythm

Hide the Last row in DataGrid
AliciaV
The currencymanager is built based on how the control is binded.
If you wanted to control the child tables view in the child datagrid you would do something like this:
Dim CM as currencymanager = ctype(me.bindingcontext(dgchild.datasource,dgchild.datamember),currencymanager
ctype(cm.list,dataview).allownew = false
That's all there is to it. Plain and simple, you almost had it, but notice I don't have to change the datasource. casting list to view allows you to change the view the grid is currently using, so there is no need to set it to a new view.
Hope that helps.
Uwa Agbonile
Rythm