I have a Winforms datagridview where the existing rows shouldn't be editable but the new row should be. So i set the ReadOnly property to true on the grid, but then i still see the new row but can't edit it. How can i combine these two properties ?
EDIT: just tried to set ReadOnly to true, but still can't edit or add new rows.
conn = new SqlCeConnection();
conn.ConnectionString = connectionstring;
conn.Open();
daFacturen = new SqlCeDataAdapter("SELECT * FROM Factuur", conn);
daFacturen.Fill(dsKlantenBeheer, "tblFactuur");
daFactuurRegels = new SqlCeDataAdapter("SELECT * FROM Factuurregel", conn);
daFactuurRegels.Fill(dsKlantenBeheer, "tblFactuurregel");
// Relation between customers and orders
DataRelation relKlantFactuur;
DataColumn relKlantFactuurcolMaster;
DataColumn relKlantFactuurcolDetail;
relKlantFactuurcolMaster = dsKlantenBeheer.Tables["tblKlant"].Columns["ID"];
relKlantFactuurcolDetail = dsKlantenBeheer.Tables["tblFactuur"].Columns["KlantID"];
relKlantFactuur = new DataRelation("RelKlantFactuur", relKlantFactuurcolMaster, relKlantFactuurcolDetail);
dsKlantenBeheer.Relations.Add(relKlantFactuur);
DataRelation relFactFactregel;
DataColumn relFactFactregelcolMaster;
DataColumn relFactFactregelcolDetail;
relFactFactregelcolMaster = dsKlantenBeheer.Tables["tblFactuur"].Columns["ID"];
relFactFactregelcolDetail = dsKlantenBeheer.Tables["tblFactuurregel"].Columns["FactuurID"];
relFactFactregel = new DataRelation("relFactFactregel", relFactFactregelcolMaster, relFactFactregelcolDetail);
dsKlantenBeheer.Relations.Add(relFactFactregel);
DataViewManager dsView = dsKlantenBeheer.DefaultViewManager;
dsView.DataViewSettings["tblKlant"].RowFilter = "Status = 0 or Status is null";
dsView.DataViewSettings["tblKlant"].Sort = "Naam, Voornaam";
// Grid Databinding
dgvFacturen.DataSource = dsView;
dgvFacturen.DataMember = "tblKlant.relKlantFactuur";
dgvFacturen.ReadOnly = true;
dgvFacturen.allowUserToAddRows = true;
AllowNew=true;
? – Angshuman AgarwalDataGridView.AllowUserToAddRows
, it says -If the DataGridView is bound to data, the user is allowed to add rows if both this property and the data source's IBindingList.AllowNew property are set to true.
– Angshuman Agarwal