hi,

i am using visual studio 2008 standard edition,
how can i add a calender control to the datagrid view, can someone please help me

thanx
in advance

what should i do after adding the class CalendarColumn to the project??
please can u give an answer.

thankxxxxxxxx

Use this code in Form_Load after that:

CalendarColumn col = new CalendarColumn();
        this.dataGridView1.Columns.Add(col);
        this.dataGridView1.RowCount = 5;
        foreach (DataGridViewRow row in this.dataGridView1.Rows)
        {
            row.Cells[0].Value = DateTime.Now;
        }

Thanks

hey the code u have posted is to display the datatime in the datagrid view, right?
what i want is a calender icon so that the user can select any date.
please can u tell me how to do this.
thnkx in advance...

Yes, that's what it does.

Try editing the cell and then you can select any date.

hey thankx farooqaaa,
first i hace to add the Calender column (without the form code)which i in the link u have provided and them add the code u have posted later in the form load event, i am rignt?

and also i have to question can u please help me???

Question 1:

and also when selecting the data from the calender column, the user has to double clil on it to select for a data, how can i make the calender icon open in one click on the cell???

Question 2:
and also how can i get the value of one cell(date time type) to a string varialbe?

appriciate if u could help me with this also ,
thanx

Answer 1: Add a CellClick event to the datagridview and use this code:

dataGridView1.BeginEdit(true);

Answer 2: You can use many methods to convert it to string. Use:

cellValue..ToShortDateString();
cellValue..ToShortTimeString();
....and others

Use the one that suits you.

Thanks

hey thanx again,
question in answer 2:

is it like this:
String a = dgvDAction[2].ToShortDateString();

please can you specify this clearly, i am not good in C#.

thankxxxxxx

hi,
is there any way i can show the calendder icon close to the datagridview cell when the cursor moves across it???
thanx
please give me an answer someone please.
thanx.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.