本文整理汇总了C#中Label类的典型用法代码示例。如果您正苦于以下问题:C# Label类的具体用法?C# Label怎么用?C# Label使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Label类属于命名空间,在下文中一共展示了Label类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PowerGrid
/// <summary>
/// Initializes a new instance of the <see cref="PowerGrid"/> class.
/// </summary>
public PowerGrid()
{
lblFooter = new Label();
PagerStyle.Mode = PagerMode.NumericPages;
PagerStyle.BackColor = Color.Gainsboro;
PagerStyle.PageButtonCount = 10;
PagerStyle.HorizontalAlign = HorizontalAlign.Center;
FooterStyle.BackColor = Color.Gainsboro;
FooterStyle.HorizontalAlign = HorizontalAlign.Center;
ShowFooter = true;
AutoGenerateColumns = false;
AllowPaging = true;
PageSize = 7;
CellSpacing = 2;
CellPadding = 2;
GridLines = GridLines.None;
BorderColor = Color.Black;
BorderStyle = BorderStyle.Solid;
BorderWidth = 1;
ForeColor = Color.Black;
Font.Size = FontUnit.XXSmall;
Font.Name = "Verdana";
ItemStyle.BackColor = Color.Beige;
AlternatingItemStyle.BackColor = Color.PaleGoldenrod;
HeaderStyle.Font.Bold = true;
HeaderStyle.BackColor = Color.Brown;
HeaderStyle.ForeColor = Color.White;
HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
AllowSorting = true;
Attributes["SortedAscending"] = "yes";
ItemCreated += new DataGridItemEventHandler(OnItemCreated);
SortCommand += new DataGridSortCommandEventHandler(OnSortCommand);
PageIndexChanged += new DataGridPageChangedEventHandler(OnPageIndexChanged);
}
示例2: Button1_Click
protected void Button1_Click(object sender, EventArgs e)
{
Label l2 = new Label();
Label1.Text = "";
l2.Text = DateTime.Now.ToString();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
conn.Open();
if (TextBox1.Text == null || TextBox1.Text == "") { Response.Write("Please share your thoughts"); }
else
{
string insert = "INSERT INTO [uptext] (Dateandtime,blogdata) VALUES (@date,@blog)";
SqlCommand comm = new SqlCommand(insert, conn);
comm.Parameters.AddWithValue("@date", l2.Text);
comm.Parameters.AddWithValue("@blog", TextBox1.Text);
comm.ExecuteNonQuery();
}
string output = "SELECT * FROM [uptext] ";
SqlCommand comm2 = new SqlCommand(output, conn);
SqlDataReader datareader = comm2.ExecuteReader();
while(datareader.Read())
{
Label1.Text += datareader["Dateandtime"].ToString() + "<br />" + "<br />";
Label1.Text += datareader["blogdata"].ToString() + "<br /> " + "<br />";
}
datareader.Close();
conn.Close();
}
示例3: gvStates_DataBound
protected void gvStates_DataBound(object sender, EventArgs e)
{
for (int i = 0; i < gvStates.Rows.Count; i++)
{
// Copy id from 5th column to invisible label in last column
Label id = new Label();
id.Visible = false;
id.Text = gvStates.Rows[i].Cells[4].Text;
gvStates.Rows[i].Cells[4].Controls.Add(id);
GridViewRow row = gvStates.Rows[i];
// Set unique text box ID
TextBox txtValue = ControlsHelper.GetChildControl(row, typeof(TextBox), "txtTaxValue") as TextBox;
txtValue.ID = "txtTaxValue" + id.Text;
// Set unique check box ID
CheckBox chkIsFlat = ControlsHelper.GetChildControl(row, typeof(CheckBox), "chkIsFlatValue") as CheckBox;
chkIsFlat.ID = "chkIsFlatValue" + id.Text;
Label lblCurrency = ControlsHelper.GetChildControl(row, typeof(Label), "lblCurrency") as Label;
if (lblCurrency != null)
{
chkIsFlat.InputAttributes["onclick"] = "switchCurrency(this.checked, '" + lblCurrency.ClientID + "')";
chkIsFlat.InputAttributes["onchange"] = "switchCurrency(this.checked, '" + lblCurrency.ClientID + "')";
}
}
}
示例4: CreateControls
private void CreateControls(Node node)
{
foreach(Node idx in node)
{
string caption = idx["Caption"].Get<string>();
string value = idx["Value"].Get<string>();
string type = idx["Type"].Get<string>();
int position = idx["Position"].Get<int>();
Panel pnl = new Panel();
pnl.CssClass = "bordered-panel";
Label cpt = new Label();
cpt.CssClass = "label-caption";
cpt.Text = caption;
pnl.Controls.Add(cpt);
Label val = new Label();
val.CssClass = "label-value";
val.Text = value;
pnl.Controls.Add(val);
// Rooting...
wrpPnl.Controls.Add(pnl);
}
}
示例5: AddEvent
private void AddEvent(object sender, Label label)
{
if (OnAdd != null)
{
OnAdd(sender, new LabelEventArg(label));
}
}
示例6: Calendar1_DayRender
protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
{
if (e.Day.IsWeekend)
{
//IsSelectable布尔属性控制日期是否可被选择
e.Day.IsSelectable = false;
}
if (e.Day.IsOtherMonth)
{
//e.Cell属性代表一个日期框
e.Cell.Text = "-";
}
//检查日期是否为3月5号。
if (e.Day.Date.Day == 5 && e.Day.Date.Month == 3)
{
e.Cell.BackColor = System.Drawing.Color.Yellow;
//向该列添加静态文本
Label lbl = new Label();
lbl.Text = "<br />学习雷锋好榜样!";
e.Cell.Controls.Add(lbl);
}
Calendar1.SelectedDate = DateTime.Now.AddDays(2).Date;
//下面的代码将使用SelectedDates选中2008年3月的每个星期天
SelectedDatesCollection theDates = Calendar1.SelectedDates;
theDates.Clear();
theDates.Add(new DateTime(2008, 3, 2));
theDates.Add(new DateTime(2008, 3, 9));
theDates.Add(new DateTime(2008, 3, 16));
theDates.Add(new DateTime(2008, 3, 23));
}
示例7: UpdateLabel
private void UpdateLabel(Label lbl)
{
//为了模拟大数据量的处理延迟,这里调用Sleep方法将时间延迟三秒
System.Threading.Thread.Sleep(10000);
//更新服务器端时间
lbl.Text = DateTime.Now.ToString();
}
示例8: report_count_rows
public void report_count_rows(Label ip_lbl, int ip_i_row_cout, string ip_str_default_message)
{
string ip_str_sum_row = "";
ip_str_sum_row += ip_str_default_message + " (Có ";
ip_str_sum_row += ip_i_row_cout + " bản ghi)";
ip_lbl.Text = ip_str_sum_row;
}
示例9: FunctionEntry
public FunctionEntry(Level level, Label label, Types.RECORD formals, Types.Type result)
{
Level = level;
Label = label;
Formals = formals;
Result = result;
}
示例10: TestNavigationImplPop
public async Task TestNavigationImplPop ()
{
NavigationPage nav = new NavigationPage ();
Label child = new Label ();
Page childRoot = new ContentPage {Content = child};
Label child2 = new Label ();
Page childRoot2 = new ContentPage {Content = child2};
await nav.Navigation.PushAsync (childRoot);
await nav.Navigation.PushAsync (childRoot2);
bool fired = false;
nav.Popped += (sender, e) => fired = true;
var popped = await nav.Navigation.PopAsync ();
Assert.True (fired);
Assert.AreSame (childRoot, nav.CurrentPage);
Assert.AreEqual (childRoot2, popped);
await nav.PopAsync ();
var last = await nav.Navigation.PopAsync ();
Assert.IsNull (last);
}
示例11: dlBind
/// <summary>
/// DataList控件绑定及分页
/// </summary>
/// <param name="intCount">每页显示的记录条数</param>
/// <param name="ds">DataSet数据集</param>
/// <param name="labPage">当前页码</param>
/// <param name="labTPage">总页码</param>
/// <param name="lbtnUp">上一页</param>
/// <param name="lbtnNext">下一页</param>
/// <param name="lbtnBack">最后一页</param>
/// <param name="lbtnOne">第一页</param>
/// <param name="dl">DataList控件对象</param>
public static void dlBind(int intCount, DataSet ds, Label labPage, Label labTPage, LinkButton lbtnUp, LinkButton lbtnNext, LinkButton lbtnBack, LinkButton lbtnOne, Repeater dl)
{
int curpage = Convert.ToInt32(labPage.Text);
PagedDataSource ps = new PagedDataSource();
ps.DataSource = ds.Tables[0].DefaultView;
ps.AllowPaging = true; //是否可以分页
ps.PageSize = intCount; //显示的数量
ps.CurrentPageIndex = curpage - 1; //取得当前页的页码
lbtnNext.Visible = true;
lbtnOne.Visible = true;
lbtnBack.Visible = true;
lbtnUp.Visible = true;
lbtnNext.Enabled = true;
lbtnBack.Enabled = true;
lbtnOne.Enabled = true;
if (curpage == 1)
{
lbtnOne.Visible = false;//不显示第一页按钮
lbtnUp.Visible = false;//不显示上一页按钮
}
if (curpage == ps.PageCount)
{
lbtnNext.Visible = false;//不显示下一页
lbtnBack.Visible = false;//不显示最后一页
}
labTPage.Text = Convert.ToString(ps.PageCount);
dl.DataSource = ps;
// dl.DataKeyField = "ID";
dl.DataBind();
}
示例12: Init
protected override void Init ()
{
var entry = new Entry {
Text = "Setec Astronomy",
FontFamily = "Comic Sans MS",
HorizontalTextAlignment = TextAlignment.Center,
Keyboard = Keyboard.Chat
};
var label = new Label ();
var binding = new Binding ("Text") { Source = entry };
var otherEntry = new Entry ();
var otherBinding = new Binding ("Text") { Source = entry, Mode = BindingMode.TwoWay };
otherEntry.SetBinding (Entry.TextProperty, otherBinding);
label.SetBinding (Label.TextProperty, binding);
var explanation = new Label() {Text = @"The Text value of the entry at the top should appear in the label and entry below, regardless of whether 'IsPassword' is on.
Changes to the value in the entry below should be reflected in the entry at the top."};
var button = new Button { Text = "Toggle IsPassword" };
button.Clicked += (sender, args) => { entry.IsPassword = !entry.IsPassword; };
Content = new StackLayout {
Children = { entry, button, explanation, label, otherEntry }
};
}
示例13: Init
protected override void Init()
{
var label = new Label { Text = "Label" };
var entry = new Entry { AutomationId = "entry" };
var grid = new Grid();
grid.Children.Add(label, 0, 0);
grid.Children.Add(entry, 1, 0);
var tableView = new TableView
{
Root = new TableRoot
{
new TableSection
{
new ViewCell
{
View = grid
}
}
}
};
Content = new StackLayout
{
Children = { tableView }
};
}
示例14: btn_SearchUsernames_OnClick
protected void btn_SearchUsernames_OnClick(object sender, EventArgs e)
{
int uID;
bool result = Int32.TryParse(Request.QueryString["userID"].ToString(), out uID);
DataTable DT = theCake.searchUsersByUserName(txt_usernameSearch.Text.Trim());
if (DT.Rows.Count == 0) // No results found
{
TableRow TR0 = new TableRow();
TableCell TC0 = new TableCell();
Label no_res = new Label();
no_res.Text = "No matches were found.";
TC0.Controls.Add(no_res);
TR0.Cells.Add(TC0);
tbl_searchResults.Rows.Add(TR0);
}
if (DT.Rows.Count >= 1) // Results found
{
foreach (DataRow DR in DT.Rows)
{
TableRow TR1 = new TableRow();
TableCell TC1 = new TableCell();
Label username_res = new Label();
username_res.Text = "<a href=\"UserProfile.aspx?userID=" + DR["ID"].ToString() + "\">" + DR["ownerAlias"].ToString() + "</a>";
TC1.Controls.Add(username_res);
TR1.Cells.Add(TC1);
tbl_searchResults.Rows.Add(TR1);
}
}
}
示例15: FacebookLoginPage
public FacebookLoginPage(FacebookConnection connection)
{
this.Title = "FacebookLoginPage";
// Connection = new FacebookConnection(key, secret, scope);
// connection.SignInCompleted += Connection_SignInCompleted;
this._Connection = connection;
this._Browser = new WebView();
//_Browser.Source = new UrlWebViewSource() { Url = _Connection.LoginUri().AbsoluteUri };
this._Connection.SignIn(this._Browser);
Label lbl = new Label ()
{ Text = "Connecting..." };
lbl.SetBinding(Label.IsVisibleProperty, "IsVisible", BindingMode.OneWay, new BooleanInverterConverter());
lbl.BindingContext = this._Browser;
this._BaseLayout = new StackLayout()
{
Orientation = StackOrientation.Vertical,
HorizontalOptions = LayoutOptions.FillAndExpand,
VerticalOptions = LayoutOptions.FillAndExpand,
};
this._BaseLayout.Children.Add(lbl);
this._BaseLayout.Children.Add(this._Browser);
this._Browser.IsVisible = false;
Padding = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0); // Accomodate iPhone status bar.
Content = this._BaseLayout;
}