![]() |
Click here to advertise with us
|
|
|||||||
| Winforms Grids Discussion related to grid controls of all types for Winforms |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
In my application I have several datagrids databinded to various tables. Within these tables I use many times a date field. The database is made in access. At the beginning I had the date format on default as long date. When I saw that time was added I changed it to shortdate. Still I get the time in the various datagrids. How do I remove the time from the datagrid so no time is entered when I create a new field. Thanks for the replies
|
|
|||
|
Kind of a newbie in vb.net. Please be patient with my questions. My application is in vb.net and the datagrids are in winforms. So why should I post it in asp.net. Is it the same in winforms (vb.net) as in asp.net? Setting the property as you said, how do I set it? I already done a search online for solutions and I found the same answer elsewhere but could not set this property. Thank you for the replies
|
|
||||
|
Try the DataGridView control instead, here you can select among various DateTime display formats in the columns DefaultCellStyle.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
Oops I had that as GridView in my head somehow, sorry. Use JohnH's suggestion with the DataGridView.
To set it open the DataGridView Tasks (little arrow in upper right corner) Click Edit Columns Select your column and click on the Defaul Cell Style property Set the Format property to 'd' |
|
|||
|
Thanks all for the replies. This worked just fine.I am trying to refresh the datagrid using parameter queries. I am filtering the grid using the date column. But I always get an empty grid. Here is the code.
Code:
Private Sub DateTimePicker1_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged
Dim dd As DateTime = CDate(CStr(Me.DateTimePicker1.Value))
Me.TextBox1.Text = dd.ToString("mm/dd/yyyy")
dd = CDate(Me.TextBox1.Text)
Me.ServicesTableAdapter.testdate(Me.Database2DataSet.Services, dd)
End Sub
|
|
|||
|
mm/dd/yyyy should be MM/dd/yyyy
What happens when you try this?: Code:
Me.ServicesTableAdapter.testdate(Me.Database2DataSet.Services, CDate(Me.DateTimePicker1.Value.ToString("MM/dd/yyyy"))
|
|
||||
|
Why would you convert DTP.Value anyway? It already returns a Date value, the return type is DateTime which is a Date.
Note that time is always a part of the Date value, if you want to reset the time part to 0 (midnight) you can use the Date property; DTP.Value.Date. Since you query items with a single Date parameter you also have to make sure the Date values in your database is normalized to time 0 in a similar fashion, else you will find no records because the time part of the Date value would differ. If this is not possible you have to query a Date range that includes any time of that day.
__________________
Some useful links: Learning videoes, Code Samples, WMI Code Creator, MSDN, The Code Project, WindowsClient.net, ASP.net, W3 Schools, Regular-Expressions.info, GDI+ FAQ
How to format posts with code blocks etc - present the problem/post properly ![]() |
|
|||
|
Strict On forces me to change it. How do I normalise my time in the database to midnight for all entries? How can I do it for the allready included entries and how will I do it in vb for the new entries. Thanks for the help. You are helping alot guys. Sorry though for the many questions
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|