datagridview datetimepicker without time format problem

i am using that c# code for datagridview datetimepicker from this link

http://msdn2.microsoft.com/en-us/netframework/system.windows.forms.idatagridvieweditingcontrol.aspx

but i do not want to print time in date, i want only print the date like "07/02/2007". how can i do that on this code. thanks



Answer this question

datagridview datetimepicker without time format problem

  • eddy2705

    Hello oceansis

    I seriously did not quite understand the code which u
    quoted ,but i know how to print only the date but not the time

    I will write the code and then explain it to you

    Dim a As Date
    Response.Write(Left(a.ToString, 9))

    as u can see ,i first declared an variable a as Date
    and when displaying the date, i made use of response.write and our very own left function in VB
    to use it perfectly and also to be safe , i first converted the a to string, by using a.tostring
    and then if u dont know what is this left function

    the general syntax of left function is Left(variable as string, number of characters which u want to display from that string)

    i thnk u can try this method in your code.....Enjoy..sorry if i could not help you,

    have a nice day

  • Dirk Reske

    Have a look at the Format property of the DateTimePicker control.. Setting it to Short seems what you want (and otherwise make it Custom and set the CustomFormat property too)


  • pratap gaikwad

    So the basic question remains: How are you "printing" the datetime

    (dateTime.ToString("dd-MM-yyyy") comes in pretty handy)


  • VitCon

    Have you tried to set the Column.DefaultCellStyle

    Don't confuse the DateTimePicker as a EditControl of DGV with the Column of the DGV. What you see is the Column not the DateTimePicker until you edit it.



  • AndyL

    Hi,oceansis

    I think you can try in this way:

    1.set datetimepicker format=custom in IDE

    2.set datetimepicker CustomFormat = dd'/'MM'/'yyyy in IDE

    or add DateTimePicker1.CustomFormat = "dd'/'MM'/'yyyy" in your code

    Regards!



  • csLearner

    oceansis wrote:
    i am printing datetime in a word document.


    Any code that demonstrates this


  • jayaraja

    i am printing datetime in a word document.
  • Cyberjunkie

    thanks timvw and SuryaManoj but i know that custom format is ok for the date format however i try to do that i am still seeing the time i could not solve that problem i did everything about custom format or setting the date to Short. as i said when i print the date i am seeing that "08/02/2007 00:00".

    thanks again for your reply.



  • datagridview datetimepicker without time format problem