Thanks, didn't realize I was doing that with the font, your suggestion is much cleaner...just an FYI, there is no ReadOnly on the cellelement...but there is the Enabled which I guess is the same thing, it works and looks nice and clean so I'm happy...
I am, however, still running into issues impelemnting your other suggestion...basically I did both things, added the MasterTemplate.AddNewBoundRowBeforeEdit and added .DefaultValuesNeeded event handler...it's not working as expected...The idea is this...the user is splitting receipts to pay for multiple invoices. As such, the receipts share pretty much all the same information with the exception of a few fields (which is what this grid view is trying to allow them to change). So I coded it up to add a new bound item, then when the defaultValuesNeeded gets fired, I grab that DataBoundItem and set all of the values to what the original ones are...In testing, I click on the new row, the default gets called and the receipt is updated properly...I manually type a new value into the cell and hit tab...at this point the cellvalidated event gets fired...when I grab the databound item during that event, it doesn't have any of the values that I set during the defaultValuesNeeded event....
here is the code, I put comments in to describe a few things...
public NewReceiptSplitWizard(String receiptNumber)
{
InitializeComponent();
totalOtherSplits = totalTrustSplits = totalAvailable = 0;
trustReceivables = new BindingList<CashReceivable>();
otherReceivables = new BindingList<CashReceivable>();
trustDGV.DataSource = trustReceivables;
otherDGV.DataSource = otherReceivables;
trustDGV.MasterTemplate.AddNewBoundRowBeforeEdit = true;
otherDGV.MasterTemplate.AddNewBoundRowBeforeEdit = true;
trustDGV.DefaultValuesNeeded += new GridViewRowEventHandler(dgv_DefaultValuesNeeded);
trustDGV.CellValidated += new CellValidatedEventHandler(dgv_CellValidated);
trustDGV.CellFormatting +=new CellFormattingEventHandler(dgv_CellFormatting);
trustDGV.UserDeletingRow += new GridViewRowCancelEventHandler(dgv_UserDeletingRow);
otherDGV.DefaultValuesNeeded += new GridViewRowEventHandler(dgv_DefaultValuesNeeded);
otherDGV.CellValidated += new CellValidatedEventHandler(dgv_CellValidated);
otherDGV.CellFormatting += new CellFormattingEventHandler(dgv_CellFormatting);
otherDGV.UserDeletingRow += new GridViewRowCancelEventHandler(dgv_UserDeletingRow);
...
}
void dgv_DefaultValuesNeeded(object sender, GridViewRowEventArgs e)
{
CashReceivable receivable = e.Row.DataBoundItem as CashReceivable;
receivable = originalReceivable.Clone();
receivable.GenerateReceiptNumber();
receivable.BillInvoiceNo = null;
receivable.BusinessFunction = null;
receivable.CheckAmount = null;
receivable.OriginalTeller = User.userName;
receivable.DtMod = DateTime.Today;
receivable.WarrantCode = null;
receivable.ApplicantName = null;
receivable.Cmmnt = null;
receivable.TrustNonTrust = (IsTrustDGV(sender)) ? CashConstants.TRUST : CashConstants.NON_TRUST;
// at this point the receivable is all setup and ready for them to enter in the new values that I have nulled out...
}
void dgv_CellValidated(object sender, CellValidatedEventArgs e)
{
bool isTrust = IsTrustDGV(sender);
CashReceivable receivable = e.Row.DataBoundItem as CashReceivable;
// at this point, receivable is blank, has NONE of the values that were defined above
... some code to set other info on the receivable
}