hi

hi ,

when i use datagrid and double click event how can i choose data from the datagrid that i want

thx



Answer this question

hi

  • Aditya

    There are certain values passed when the user double click on a DataGrid (WinForm)

    private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
    {
    this.dataGridView1[e.ColumnIndex, e.RowIndex].Value = "ALI";
    // By the help of Row/Column Index you can do anything with that Row/Cell
    }



  • Anil Dogra

    hi , where should i write this function

    sry im new in c#

    thx


  • Rune Nergard

    i use that code and its work with me but i dont know f its good code or not

    int n=dataGrid1.CurrentRowIndex;

    string id=dataGrid1[n,0].ToString();

    Form14 obj=new Form14(id);

    obj.ShowDialog();

    ,


  • Doug P.

    i tried it but there is that error happened

    The type or namespace name 'DataGridViewCellEventArgs' could not be found (are you missing a using directive or an assembly reference )

    do u need 2 include something

    thx


  • Walter Luszczyk

    Use this code in the Double Click Event of the DataGrid



  • kbach_10

    I just showed you a sample code like you can get the value from that cell by using the following code

    this.dataGridView1[e.ColumnIndex, e.RowIndex].Value

    beacuse most of the properties provides getters/setters




  • Sir Limey

    I used the same code given and got the correct results. For example: This code simplifies what you are trying to do.

    private void testPhaseDataGridView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)

    {

    String MyString = this.testPhaseDataGridView["dataGridViewTextBoxColumn2", e.RowIndex].Value.ToString();

    MessageBox.Show(MyString);

    Make sure you enable the event "cell double click" which in turn creates the method, testPhaseDataGridView_CellDoubleClick.

    Also, in your last example you placed your row index where the column should be.



  • redviking2006

    hi ,

    i wanna retrive from the datagrid not 2 update it is it the same way

    thx


  • MicroAdmin

    Can you show me the code of that event


  • hi