PDA

View Full Version : Format date trong datagrid



Kesitinh1976
30-11-2004, 10:19
Các bạn ơi, chỉ giùm mình cái này với.
Hiện mình đang sử dụng gridEx của components Janus.
Mình dùng calendar combo trong datagrid, và muốn hiển thị cột ngày trong grid theo định dạng : dd/MM/yyyy
Mình chọn Formatstring của cột ngày of grid theo đúng định dạng như trên. Kết quả là hiển thị đúng theo định dạng ngày/tháng/năm như đã chọn.
Nhưng khi chọn ngày từ calendar combo trong cột của grid thì lúc đó nó có định dạng phụ thuộc vào định dạng của hệ thống (giả sử là M/d/yyyy).
Như vậy sau khi chọn xong thì các rows trên grid có hai định dạng ngày ...
Làm sao hiệu chỉnh định dạng ngày của calendar combo trong cột của grid????
ai biết chỉ giùm mình đi ...mình bí rùi...
Thanks alot
KST

alleycat
30-11-2004, 12:28
Tôi chưa hiểu rõ câu hỏi lắm. Nhưng bạn có thể work around bằng cách sử dụng biến trung gian mà. strDate = Format(Trim$(myCal.Text), "dd/MM/yyyy", tùy, tùy) sau đó trả về cho grid (tôi cũng ko rành cái gridEX đâu nhé). Mà đúng là thằng Yanus nó lấy ngày tháng format theo mặc định của hệ thống thật: http://www.janusys.com/janus/beta/support_y2k.htm

The Janus GridEX control versions 1.5f, 1.6d and 2000 are compliant with the year 2000. It has been tested under the operating systems: Windows 95/98 & Windows NT 4.0 with a system date greater than 12/31/1999. Where applicable, the controls in this package handle the representation of dates as the Windows operating systems handles the representation of dates.

The default format and display of dates are taken from the International/Regional settings section of the operating system. When entering a date between 01/01/2000 and 12/31/2029, it is not required that you enter the century. For dates that are greater than 12/31/2029 it is required to enter the century. For example, the date 12/01/05 would represent the date 12/01/2005. All dates that are greater than 12/31/99 will be displayed with the full century as well.

Janus GridEX converts 2-digit years to 4-digit years based on the default in the Automation libraries for all date functions. Janus GridEX converts 2-digit years to the 1900s if the 2-digit year is between 30 and 99. If the 2-digit year is between 00 and 29, the date is converted to the 2000s.

The Janus ButtonBar does not use date functions

Thanh Hong Duc
22-07-2009, 14:45
Ai biết làm sao để định dạng 1 cột trong Datagridview của window form C# theo dạng dd/MM/yyyy thì giúp mình với. ý mình là mình có 1 bảng SV gồm có họ tên và ngày sinh. khi hiển thị dữ liệu lên Datagridview thì trường ngày sinh hiển thị ở dạng MM/dd/yyyy. Làm sao để nó hiển thị ở dạng dd/MM/yyyy. Cảm ơn nhiều

lethanhcong
02-08-2010, 20:02
Bạn muốn định dạng datetimepicker có dạng dd/MM/yyyy thì bạn vào thuộc tính của datetimepicker chọn Format là Custom và tìm đến thuộc tính Custom Format bạn gõ dd/MM/yyy
Còn nếu bạn muốn hiện dd/MM/yyyy thì bạn vào Edit Columns của DataGridview chọn cột mà bạn muốn hiển thị sau đó trong phần Appearance bạn chọn thuộc tính DefaultCellStyle, sau đó nó đưa bạn đến một cửa sổ mới, bạn tìm thuộc tính Format nằm dưới Behavier bạn chọn gõ dd/MM/yyyy.
vậy là xong.Không biết có đúng ý bạn không? thân chào