>If I'm using mmDataGrid to display child records, and I have AddRowsWithDownArrow = true, it doesn't automatically populate the parent foreign key field (as it does when I call NewRow() directly).
>
>Should it do this? And if not, where's the best place to hook into for getting this field populated (and any other defaults I might have).
>
If you set up the DefaultValue for your DataColumn it looks like it honors those. That won't help you if you have a DataRelation between your tables. Here is how to hook into the event that fires when you down arrow in the datagrid. You must be databound to the DefaultView (grid.BindingSourceMember=BizObj.DefaultView)
DataView dv = det.GetCurrentDataSet().Tables["OrderDetail"].DefaultView;
dv.ListChanged += new ListChangedEventHandler(det_ListChanged);
Then in the event handler
private void det_ListChanged(Object sender, ListChangedEventArgs e)
{
if (e.ListChangedType == ListChangedType.ItemAdded)
{
DataRowView drv = ((DataView)sender)[e.NewIndex];
if (drv.IsNew)
{ // Add any defaults here
drv["iqty"] = 1;
drv["cdesc"] = "ItemDescription";
}
}
}