TitleFormat 枚举
指定 Calendar 控件中显示的月份的标题格式。
**命名空间:**System.Web.UI.WebControls
**程序集:**System.Web(在 system.web.dll 中)
语法
声明
Public Enumeration TitleFormat
用法
Dim instance As TitleFormat
public enum TitleFormat
public enum class TitleFormat
public enum TitleFormat
public enum TitleFormat
成员
成员名称 | 说明 | |
---|---|---|
Month | 显示标题,只显示月份而不显示年份(如“1 月”)。 | |
MonthYear | 显示标题,同时显示月份和年份(如“2000 年 1 月”)。 |
备注
TitleFormat 枚举表示 Calendar 控件的不同标题格式。
示例
下面的代码示例演示如何将日历标题从默认格式 (MonthYear) 更改为 Month 格式。若要运行该示例,请创建名为 WebForm1
的 Web 窗体页,然后用示例代码替换 Page_load
方法。
Private Sub Page_Load(sender As Object, e As System.EventArgs)
' Change the title format of Calendar1.
Calendar1.TitleFormat = TitleFormat.Month
End Sub 'Page_Load
private void Page_Load(object sender, System.EventArgs e)
{
// Change the title format of Calendar1.
Calendar1.TitleFormat = TitleFormat.Month;
}
private void Page_Load(Object sender, System.EventArgs e)
{
// Change the title format of Calendar1.
calendar1.set_TitleFormat(TitleFormat.Month);
} //Page_Load
<%@ Page Language="VB" AutoEventWireup="True" %>
<html>
<script runat="server" >
Sub Selection_Change(sender As Object, e As EventArgs)
' Set the title format.
Calendar1.TitleFormat = CType(ModeList.SelectedIndex, TitleFormat)
End Sub
</script>
<body>
<form runat="server">
<h3> Calendar TitleFormat Example </h3>
Choose the title format.
<br><br>
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br><br>
<table cellpadding="5">
<tr>
<td>
Format:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ModeList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> Month </asp:ListItem>
<asp:ListItem Selected="True"> MonthYear </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="True" %>
<html>
<script runat="server" >
void Selection_Change(Object sender, EventArgs e)
{
// Set the title format.
Calendar1.TitleFormat = (TitleFormat)ModeList.SelectedIndex;
}
</script>
<body>
<form runat="server">
<h3> Calendar TitleFormat Example </h3>
Choose the title format.
<br><br>
<asp:Calendar id="Calendar1"
ShowGridLines="True"
ShowTitle="True"
runat="server"/>
<br><br>
<table cellpadding="5">
<tr>
<td>
Format:
</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ModeList"
AutoPostBack="True"
OnSelectedIndexChanged="Selection_Change"
runat="server">
<asp:ListItem> Month </asp:ListItem>
<asp:ListItem Selected="True"> MonthYear </asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</form>
</body>
</html>
平台
Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
System.Web.UI.WebControls 命名空间
Calendar 类
Calendar.TitleFormat 属性