whan SP FieldMultiColumn
物体使用方法override Base FieldControl FieldRenderingControl
装载从继承的物体 Base FieldControl
因此,继承<代码>的物体 地面对代码>有一种称为“方法”
protected override void RenderFieldForDisplay(HtmlTextWriter output){}
这样,你就可以使你控制适合你。
您可使用以下实例:
namespace SharePointTestApplication
{
public class UserChoiceColumn:SPFieldMultiColumn
{
public UserChoiceColumn(SPFieldCollection fields, string fname)
: base(fields, fname) { }
public UserChoiceColumn(SPFieldCollection fields, string tname, string dname)
: base(fields, tname, dname) { }
public override BaseFieldControl FieldRenderingControl
{
get
{
BaseFieldControl ctr = new UserChoiceColumnControlType();
ctr.FieldName = this.InternalName;
return ctr;
}
}
public override string GetFieldValueAsHtml(object value)
{
SPFieldMultiColumnValue mcv = new SPFieldMultiColumnValue(value.ToString());
return string.Format("{0} , {1}",mcv[0],mcv[1]);
}
}
public class UserChoiceColumnControlType : BaseFieldControl
{
#region Protected Members
protected TextBox TextBox1;
protected TextBox TextBox2;
#endregion
protected override string DefaultTemplateName
{
get
{
return "UserChoiceColumnTemplate";
}
}
protected override void CreateChildControls()
{
base.CreateChildControls();
TextBox1 = (TextBox)this.TemplateContainer.FindControl("TextBox1");
TextBox2 = (TextBox)this.TemplateContainer.FindControl("TextBox2");
}
public override object Value
{
get
{
this.EnsureChildControls();
SPFieldMultiColumnValue mcv = new SPFieldMultiColumnValue(2);
mcv[0] = TextBox1.Text;
mcv[1] = TextBox2.Text;
return mcv;
}
set
{
this.EnsureChildControls();
SPFieldMultiColumnValue mcv = (SPFieldMultiColumnValue)this.ItemFieldValue;
TextBox1.Text = mcv[0];
TextBox2.Text = mcv[1];
}
}
**protected override void RenderFieldForDisplay(HtmlTextWriter output)
{
output.Write("hello world");
// base.RenderFieldForDisplay(output);
}**
}
}