Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
code is
dgShop.Rows[i].Cells[2].Value = ds1.Tables[0].Rows[0].ItemArray[0].ToString();
and then

C#
private void dgShop_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2 && e.RowIndex >= 0)
            {
                if (e.RowIndex == 0)
                {
                    dgShop.Rows[e.RowIndex].Cells[3].Value = "1";
                    dgShop.Rows[e.RowIndex].Cells[4].Value = dgShop.Rows[e.RowIndex].Cells[2].Value;
                }
                else
                {
                    dgShop.Rows[e.RowIndex].Cells[3].Value = (Convert.ToInt32(dgShop.Rows[e.RowIndex - 1].Cells[4].Value) + 1).ToString();
                    dgShop.Rows[e.RowIndex].Cells[4].Value = (Convert.ToInt32(dgShop.Rows[e.RowIndex].Cells[2].Value) + Convert.ToInt32(dgShop.Rows[e.RowIndex - 1].Cells[4].Value)).ToString();
                }

            }
        }

It done but it is automatic blank
Posted
Comments
Richard MacCutchan 21-Feb-15 13:31pm    
Please edit your question and show exactly where the error occurs, and explain the precise details.

1 solution

1. Does your XAML code contain a DataContext statement that references your VM?
XML
<window ...="">
    <grid>DataContext="{StaticResource vm}">
        <!-- more stuff goes here -->
    </grid>
</window>

2. Does your VM implement the INotifyPropertyChanged interface?
C++
class FooVM : INotifyPropertyChanged
{
    #region Implementation of INotifyPropertyChanged

    public event PropertyChangedEventHandler PropertyChanged;

    #endregion

    // more stuff goes here
}


3. After each change to dgShow, are you calling the PropertyChanged event handler with the XAML name of dgShow?
C#
//  call this with the property name after every change!
public void NotifyPropertyChanged(string propertyName = "")
{
    if (PropertyChanged != null)
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}


The XAML model separates the display model from the underlying data model. Not only must the data model be notified when the display is changed, but the display must be notified when the data model is changed.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900