Click here to Skip to main content
16,007,163 members
Home / Discussions / C#
   

C#

 
GeneralRe: need help to develop C# software Pin
Soulblazer24-Jul-05 17:16
Soulblazer24-Jul-05 17:16 
GeneralRe: need help to develop C# software Pin
[Marc]24-Jul-05 17:41
[Marc]24-Jul-05 17:41 
GeneralRe: need help to develop C# software Pin
Soulblazer24-Jul-05 17:41
Soulblazer24-Jul-05 17:41 
GeneralRe: need help to develop C# software Pin
Vasudevan Deepak Kumar24-Jul-05 22:57
Vasudevan Deepak Kumar24-Jul-05 22:57 
GeneralRe: need help to develop C# software Pin
Christian Graus24-Jul-05 18:34
protectorChristian Graus24-Jul-05 18:34 
QuestionWilling to check for errors or loose ends? Pin
WetRivrRat24-Jul-05 13:23
WetRivrRat24-Jul-05 13:23 
GeneralAbout DataGrid Pin
Amir Jalaly24-Jul-05 6:24
Amir Jalaly24-Jul-05 6:24 
GeneralRe: About DataGrid Pin
Alomgir Miah24-Jul-05 7:16
Alomgir Miah24-Jul-05 7:16 
The DataGrid class does not have a property that controls whether a new row can be added. But the DataView class does have such a property (along with some others such as AllowEdit and AllowDelete). Here is code that will turn off the append row by getting at the dataview associated with the datagrid.

string connString = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";

string sqlString = "SELECT * FROM customers";



// Connection object

OleDbConnection connection = new OleDbConnection(connString);



// Create data adapter object

OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sqlString, connection);



// Create a dataset object and fill with data using data adapter's Fill method

DataSet dataSet = new DataSet();

dataAdapter.Fill(dataSet, "customers");



// Attach dataset's DefaultView to the datagrid control

dataGrid1.DataSource = dataSet.Tables["customers"];



//no adding of new rows thru dataview...

CurrencyManager cm = (CurrencyManager)this.BindingContext[dataGrid1.DataSource, dataGrid1.DataMember];

((DataView)cm.List).AllowNew = false;


If your datagrid contains links, then adding Navigate handler such as the one below to disallow the AddNew.

private void DataGrid1_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)

{

if(ne.Forward)

{

CurrencyManager cm = (CurrencyManager)BindingContext[DataGrid1.DataSource,DataGrid1.DataMember];

DataView dv = (DataView) cm.List;

dv.AllowNew = false;

}

}



Live Life King Size
Alomgir Miah
GeneralAbout:: Bending the .NET PropertyGrid to Your Will:: Fill value at run time Pin
hardew24-Jul-05 4:00
hardew24-Jul-05 4:00 
GeneralRe: About:: Bending the .NET PropertyGrid to Your Will:: Fill value at run time Pin
Luis Alonso Ramos24-Jul-05 19:19
Luis Alonso Ramos24-Jul-05 19:19 
GeneralRe: About:: Bending the .NET PropertyGrid to Your Will:: Fill value at run time Pin
LongRange.Shooter25-Jul-05 10:13
LongRange.Shooter25-Jul-05 10:13 
Questionwhat is the Event when click on maximize button Pin
Sasuko24-Jul-05 3:55
Sasuko24-Jul-05 3:55 
AnswerRe: what is the Event when click on maximize button Pin
Alomgir Miah24-Jul-05 8:49
Alomgir Miah24-Jul-05 8:49 
GeneralRe: what is the Event when click on maximize button Pin
Sasuko24-Jul-05 11:14
Sasuko24-Jul-05 11:14 
QuestionWhen is my Access db to large? Pin
sa}{en24-Jul-05 3:43
sa}{en24-Jul-05 3:43 
AnswerRe: When is my Access db to large? Pin
Dave Kreskowiak24-Jul-05 4:42
mveDave Kreskowiak24-Jul-05 4:42 
AnswerRe: When is my Access db to large? Pin
DavidNohejl24-Jul-05 4:51
DavidNohejl24-Jul-05 4:51 
AnswerRe: When is my Access db to large? Pin
Scott Serl24-Jul-05 13:46
Scott Serl24-Jul-05 13:46 
AnswerRe: When is my Access db to large? Pin
Robert Rohde24-Jul-05 19:56
Robert Rohde24-Jul-05 19:56 
GeneralRe: When is my Access db to large? Pin
sa}{en25-Jul-05 9:28
sa}{en25-Jul-05 9:28 
Generalusing directive Pin
andrewpritchie24-Jul-05 3:40
andrewpritchie24-Jul-05 3:40 
GeneralRe: using directive Pin
DavidNohejl24-Jul-05 4:31
DavidNohejl24-Jul-05 4:31 
GeneralRe: using directive Pin
Dave Kreskowiak24-Jul-05 4:37
mveDave Kreskowiak24-Jul-05 4:37 
QuestionOutlook 2003 Add-In with C#? Pin
fcn][Stampede24-Jul-05 2:07
fcn][Stampede24-Jul-05 2:07 
AnswerRe: Outlook 2003 Add-In with C#? Pin
Brian Delahunty24-Jul-05 2:20
Brian Delahunty24-Jul-05 2:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.