C# 1.1 DataGrid question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jason Huang

    #1

    C# 1.1 DataGrid question

    Hi,

    In my C# 1.1 windows form project, I have a form Form1 which has a DataGrid
    DataGrid1.
    In the DataGrid1, I have 3 columns, they are Unit, UnitPrice, TotalPrice.
    What I want is in this DataGrid, if a user modify the Unit or UnitPrice,
    then the value of the column TotalPrice will respond returning the value of
    Unit * UnitPrice, after the user press the button.
    I tried in the KeyPress event but I have encountered some problem,
    if the Unit origin value is 8 ,and a user typed in 9, the event get the
    value 8 , not 9.
    What event do I need to use to get the value of 9 or I need to do extra
    manipulation in the KeyPress event?
    Thanks for help.


    Jason


  • =?Utf-8?B?U29tIE5hdGggU2h1a2xh?=

    #2
    RE: C# 1.1 DataGrid question

    hi use this thsi is cell click event when after updating unit or unit price u
    will click the row again u will get the updated value

    private void dataGridView2_C ellClick(object sender,
    DataGridViewCel lEventArgs e)
    {
    dataGridView2.R ows[e.RowIndex].Cells[2].Value =
    Convert.ToInt32 (dataGridView2. Rows[e.RowIndex].Cells[0].Value) *
    Convert.ToInt32 (dataGridView2. Rows[e.RowIndex].Cells[1].Value);
    }

    "Jason Huang" wrote:
    Hi,
    >
    In my C# 1.1 windows form project, I have a form Form1 which has a DataGrid
    DataGrid1.
    In the DataGrid1, I have 3 columns, they are Unit, UnitPrice, TotalPrice.
    What I want is in this DataGrid, if a user modify the Unit or UnitPrice,
    then the value of the column TotalPrice will respond returning the value of
    Unit * UnitPrice, after the user press the button.
    I tried in the KeyPress event but I have encountered some problem,
    if the Unit origin value is 8 ,and a user typed in 9, the event get the
    value 8 , not 9.
    What event do I need to use to get the value of 9 or I need to do extra
    manipulation in the KeyPress event?
    Thanks for help.
    >
    >
    Jason
    >
    >
    >

    Comment

    Working...