mtxtBdate.Value = dataGridView1.SelectedRows[0].Cells["Birthdate"].Value.ToString();

i want this on data Grid view.. this type of syntax use in all other textboxs.. but now how to use this datepicker control syntax.. this sytax is wrong plzz tell me write

meas any date that user select on the datetimepicker is show on the datagrid..

mtxtfname.text = datagridView1.SelectRows[0].Cells["fIrstname"].value.ToString();

this sytanx will for text box but for data picker ???

If i understand correctly, you want Birthday date cell in dgw to reflect the datetimepicker control?
Can you confirm that?

What you should do is get the Date from the DGV cell.

So lets say the user clicks on the cell with date in...you should use the CellContentClick to determine where has been clicked on the DGV.

(Remember cell and column indexes are zero based)

//use the cell contentclick event
                    private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
           int row = e.RowIndex;//this is the row number that the user clicked...remember it is 0 based.

           DatePicker.value = (DateTime)DGV.Rows[row].Cells[1].Value;

           //'Cells[1]' is basically the cell in your date column....I am assuming that the column is going to be the same one all the time...if it is not then you can do 'int column = e.ColumnIndex' and use 'ColumnIndex', (Eg .Rows[row].Cells[column].Value;).

        }

Edited 4 Years Ago by james6754

That is the main problem of SL and WPF, If you do not know how to create behavior.
How to solve a few suggestion:
1. Create staticResource
2. Subscribe the control that placed in side DataTemplate to load event the referent in code.

Edited 4 Years Ago by pritaeas: Removed self promotion link.

This article has been dead for over six months. Start a new discussion instead.