silvanag
9 years ago
Hi All.
I have this problem: i have to create a grid with several columns for date fields and I do not know how to get the empty cell for a given nothing (or 00:00:0000).

The tests I did with sFmtString doesn't work.

I know I can create the grid, and after it has been created i can read all the cells and set the correct value with a function, but this is very time consuming.

Another thing: I thought to transform the Date field in TXT, but I lose the possibility of automatic sorting. Phew !! I am going crazy.

Can someone help me to automatically set the format of a column of date field?

VB6 Language.
Tnx to all.
Igor/10Tec
9 years ago
Frankly speaking, I feel that I do not understand the problem properly or completely.

If you need to set the desired format string for the whole column as the default format string and to avoid executing a loop to set this format string after the cells have been created, you can use the ColDefaultCell object property.

If you need to implement a sophisticated cell editor that allows your users to enter time values in the specified format, you need to code this logic in the TextEdit* events like TextEditKeyDown.

Can you give us more info about your task? It would be nice to see an accompanying screenshot too.
Dan
9 years ago
silvanag, what are you using to represent a "nothing" date? If you use Null it works fine, you get an empty date cell. If you use 0 you'll get 30th Dec 1899 because that's what date 0 is in VB6.

Here's some sample code:

With iGrid1
   .Clear True

   .AddCol "Date", "Date"
   .ColDefaultCell(1).sFmtString = "dd/mm/yyyy hh:nn:ss"

   .RowCount = 4

   .CellValue(1, 1) = CDate("10 feb 2016 09:02")
   .CellValue(2, 1) = Null
   .CellValue(3, 1) = CDate("2 dec 2015 08:01")
   .CellValue(4, 1) = 0

   .AutoWidthCol 1

End With

As you can see the dates look like dates, the null row is empty, and the 0 row is 31/12/1899 00:00:00. The column is correctly sortable as internally iGrid has the data type as a date rather than a string.

igrid dates screenshot.png

Click to View Image158 View(s)




Dan
silvanag
9 years ago
Originally Posted by: Dan 

silvanag, what are you using to represent a "nothing" date? If you use Null it works fine, you get an empty date cell. If you use 0 you'll get 30th Dec 1899 because that's what date 0 is in VB6.


Grazie Mille!! :-)
Tnx a lot! :-))

I understand, very good explanation. In fact my problem is that I have the dates = 0: i will check the database.