In this Custom Content Query Web Part the following code works. I'm able to change the Web Part title and the ToolPart Title:
public class CustomWebPart1 : ContentByQueryWebPart
{
public override ToolPart[] GetToolParts()
{
ToolPart[] toolPartArray = base.GetToolParts();
return new ToolPart[] { new CustomContentQueryWebPartToolPart(), toolPartArray[0], toolPartArray[1] };
}
}
public class CustomContentQueryWebPartToolPart : ToolPart
{
TextBox txt1;
CustomWebPart1 wp;
public CustomContentQueryWebPartToolPart()
{
this.Title = "My Custom Properties";
}
protected override void CreateChildControls()
{
txt1 = new TextBox();
this.Controls.Add(txt1);
base.CreateChildControls();
}
public override void ApplyChanges()
{
this.Title = "ToolPart Title: " + txt1.Text;
wp = this.WebPartToEdit as CustomWebPart1;
wp.Title = "WebPart Title: " + txt1.Text;
base.ApplyChanges();
}
}
But if i change the position in the array (which is the display order of the web part properties) changing the Web Part title doesn't work anymore!
public override ToolPart[] GetToolParts()
{
ToolPart[] toolPartArray = base.GetToolParts();
return new ToolPart[] { toolPartArray[0], toolPartArray[1], new CustomContentQueryWebPartToolPart() };
}
What's wrong here? Is this a bug? Changing the ToolPart Title still works.