PC Review


Reply
Thread Tools Rate Thread

DataGrid on DataViewManager, no AllowNew?

 
 
Walt Borders
Guest
Posts: n/a
 
      29th Jun 2004
Hi,

I'm using a DataViewManager to sort the children of parent-child
nested tables in a DataSet. The DataViewManager and DataGrid work
very well doing every thing that is needed, except...

The DataGrid needs to:

AllowDelete = false;
AllowNew = false;
AllowEdit = false;

On the base tables in the dataSet, I set those values using
"DefaultView".

I'm also using DataGridTableStyle and setting the columns to "ReadOnly
= true".

Neither helps. Is there a better way to control the, AllowDelete,
AllowNew and AllowEdit for a dataGrid on a DataViewManager?

My environment: .NET, framework 1.1, C#, windows forms.

Thanks in advance
 
Reply With Quote
 
 
 
 
ClayB [Syncfusion]
Guest
Posts: n/a
 
      29th Jun 2004
I think you can subscribe to the DataGrid's Navigate event, get the
CurrencyManager there, and set the AllowNew property of the
CurrencyManager's List at that point. Below is some code.
=============
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools


private void Form1_Load(object sender, System.EventArgs e)
{
DataTable parentTable = GetParentTable();
DataTable childTable = GetChildTable();
DataSet ds = new DataSet();
ds.Tables.AddRange(new DataTable[]{parentTable, childTable});

DataRelation parentToChild = new DataRelation("ParentToChild",
parentTable.Columns["parentID"], childTable.Columns["ParentID"]);

ds.Relations.AddRange(new DataRelation[]{parentToChild});

this.dataGrid1.DataSource = parentTable.DefaultView;
parentTable.DefaultView.AllowNew = false;

this.dataGrid1.Navigate += new
NavigateEventHandler(dataGrid1_Navigate);
}

private void dataGrid1_Navigate(object sender, NavigateEventArgs e)
{
if(e.Forward)
{
CurrencyManager cm =
(CurrencyManager)this.dataGrid1.BindingContext[this.dataGrid1.DataSource,
this.dataGrid1.DataMember];
((DataView)cm.List).AllowNew = false;
}
}

"Walt Borders" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm using a DataViewManager to sort the children of parent-child
> nested tables in a DataSet. The DataViewManager and DataGrid work
> very well doing every thing that is needed, except...
>
> The DataGrid needs to:
>
> AllowDelete = false;
> AllowNew = false;
> AllowEdit = false;
>
> On the base tables in the dataSet, I set those values using
> "DefaultView".
>
> I'm also using DataGridTableStyle and setting the columns to "ReadOnly
> = true".
>
> Neither helps. Is there a better way to control the, AllowDelete,
> AllowNew and AllowEdit for a dataGrid on a DataViewManager?
>
> My environment: .NET, framework 1.1, C#, windows forms.
>
> Thanks in advance



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DataGrid -- Hide Add New Row -- DataView AllowNew ehdoty@gmail.com Microsoft Dot NET Compact Framework 3 7th Mar 2007 08:17 PM
DataGrid, AllowNew, pasting inserts rows whitecrow Microsoft C# .NET 1 10th Jan 2006 03:00 PM
datagrid and dataviewmanager =?Utf-8?B?eW9ibw==?= Microsoft Dot NET Framework 0 28th Feb 2005 01:07 PM
DataGrid AllowNew = False Doug Bell Microsoft VB .NET 3 8th Dec 2004 03:51 AM
Master-Detail datagrid[allownew = false] Agnes Microsoft VB .NET 1 17th Aug 2004 08:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:00 AM.