using System;
using System.ComponentModel;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace XControl
{
/// <summary>ÕûÐÍÑ¡Ôñ¿Ø¼þ¡£</summary>
[Description("ÕûÐÍÑ¡Ôñ¿Ø¼þ")]
[ToolboxData("<{0}:IntCheckBox runat=server></{0}:IntCheckBox>")]
[ToolboxBitmap(typeof(CheckBox))]
[ControlValueProperty("Value")]
public class IntCheckBox : CheckBox
{
/// <summary>Ñ¡ÖÐÖµ</summary>
[Category(" רÓÃÊôÐÔ"), DefaultValue(1), Description("Ñ¡ÖÐÖµ")]
public Int32 SelectedValue
{
get
{
String str = (String)ViewState["SelectedValue"];
if (String.IsNullOrEmpty(str)) return 1;
Int32 k = 1;
if (!int.TryParse(str, out k)) return 1;
return k;
}
set
{
ViewState["SelectedValue"] = value.ToString();
}
}
/// <summary>·ÇÑ¡ÖÐÖµ</summary>
[Category(" רÓÃÊôÐÔ"), DefaultValue(0), Description("·ÇÑ¡ÖÐÖµ")]
public Int32 UnSelectedValue
{
get
{
String str = (String)ViewState["UnSelectedValue"];
if (String.IsNullOrEmpty(str)) return 0;
Int32 k = 0;
if (!int.TryParse(str, out k)) return 0;
return k;
}
set
{
ViewState["UnSelectedValue"] = value.ToString();
}
}
/// <summary>ÊÇ·ñ½ö½öÑ¡ÖÐ</summary>
[Category(" רÓÃÊôÐÔ"), DefaultValue(false), Description("µ±Ç°ÖµValueÊÇ·ñ½ö½öµÈÓÚÑ¡ÖÐֵʱ²ÅÑ¡ÖÐ")]
public Boolean OnlySelect
{
get
{
String str = (String)ViewState["OnlySelect"];
if (String.IsNullOrEmpty(str)) return false;
Boolean k = false;
if (!Boolean.TryParse(str, out k)) return false;
return k;
}
set
{
ViewState["OnlySelect"] = value.ToString();
}
}
/// <summary>µ±Ç°Öµ</summary>
[Category(" רÓÃÊôÐÔ"), DefaultValue(0), Description("µ±Ç°Öµ")]
public Int32 Value
{
get
{
return Checked ? SelectedValue : UnSelectedValue;
}
set
{
if (OnlySelect)
{
//Ö»ÓеÈÓÚÑ¡ÖÐֵʱ²ÅÑ¡ÖÐ
Checked = (value == SelectedValue);
}
else
{
Checked = !(value == UnSelectedValue);
}
}
}
}
}
|