If you press F4 or double-click a date-time cell when it is in edit mode, a pop-up calendar (or pop-up clock) appears, as shown in the following figures. The calendar control appears if you have the date-time cell set to any format besides TimeOnly format. The clock control appears if you have the format set to TimeOnly. The date you choose from the calendar (or the time you choose from the clock) is placed in the date-time cell. If you want the present date and time, in the calendar control click Today; if you want the present time, in the clock control click Now.
Pop-Up Calendar Control | Pop-Up Clock Control |
---|---|
You can specify normal and abbreviated day names, normal and abbreviated month names, and the text for the buttons at the bottom of the control. Use the SetCalendarText method of the DateTimeCellType class to set these.
Note that the text appears centered on the button. If you set custom text for the buttons, try to limit your text to eight or nine characters in length. The button will display ten characters, but the first and last appear very close to the edges.
When using the controls, you must click the OK or Cancel button to close the control. The Today (or Now) button simply sets the value in the cell to the current date (or time).
For more information on setting the format of the date-time cell, refer to the DateTimeFormat enumeration.
For information on the editable cell types, refer to Working with Editable Cell Types.
For information on other features of cell types, refer to Understanding Additional Features of Cell Types.
The following example sets the text of the buttons and specifies day and month names in array lists.
C# |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.DateTimeCellType datecell = new FarPoint.Win.Spread.CellType.DateTimeCellType(); string[] daynames = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; string[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; string[] dayabbrev = {"Su","My","Ty","Wy","Th","Fy","Sy"}; string[] mthabbrev = {"Jy","Fy","Mh","Al","My","Jn","Jl","At","Sr","Or","Nr","Dr"}; string okbuttn = "Fine"; string cancelb = "Quit"; datecell.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined; datecell.UserDefinedFormat = "dddd MMMM d, yyyy"; datecell.SetCalendarText(daynames,months,dayabbrev,mthabbrev,okbuttn, cancelb); fpSpread1.ActiveSheet.Cells[1, 1].CellType = datecell; fpSpread1.ActiveSheet.Cells[1, 1].Value = System.DateTime.Now; fpSpread1.ActiveSheet.Columns[1].Width = 130; |
VB |
Copy Code
|
---|---|
FarPoint.Win.Spread.CellType.DateTimeCellType datecell = new FarPoint.Win.Spread.CellType.DateTimeCellType(); string[] daynames = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; string[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; string[] dayabbrev = {"Su","My","Ty","Wy","Th","Fy","Sy"}; string[] mthabbrev = {"Jy","Fy","Mh","Al","My","Jn","Jl","At","Sr","Or","Nr","Dr"}; string okbuttn = "Fine"; string cancelb = "Quit"; datecell.DateTimeFormat = FarPoint.Win.Spread.CellType.DateTimeFormat.UserDefined; datecell.UserDefinedFormat = "dddd MMMM d, yyyy"; datecell.SetCalendarText(daynames,months,dayabbrev,mthabbrev,okbuttn, cancelb); fpSpread1.ActiveSheet.Cells[1, 1].CellType = datecell; fpSpread1.ActiveSheet.Cells[1, 1].Value = System.DateTime.Now; fpSpread1.ActiveSheet.Columns[1].Width = 130; |
Or right-click on the cell or cells and select Cell Type. From the list, select the cell type. In the CellType editor, set the properties you need. Click Apply.