How to add custom control?
Hi,
I write a custom control MyTextObject inherited from TextObject, it does nothing only inherited base behavior,
then i register it. in designer, i drag and drop MyTextObject, set expression, like Text = "[MyTable.MyField]" , and preview, it's ok, everything is well.
But if i drag and drop another TextObject, and set it's Text an error expression, like Text = "[errortest]". when i preview, error message will display a namespace error in MyTextObject not in TextObject which is true error.
If i add my assembly in script's ReferenceAssemblies, error message will display correctly, but i have to add my assembly in every report.
Do you have a good idea?
thanks.
my code like following:
namespace MySoft.Report
{
public class MyTextObject: TextObject
{
}
}
//init
RegisteredObjects.Add(typeof(MyTextObject), "ReportPage", null, "MyText");
I write a custom control MyTextObject inherited from TextObject, it does nothing only inherited base behavior,
then i register it. in designer, i drag and drop MyTextObject, set expression, like Text = "[MyTable.MyField]" , and preview, it's ok, everything is well.
But if i drag and drop another TextObject, and set it's Text an error expression, like Text = "[errortest]". when i preview, error message will display a namespace error in MyTextObject not in TextObject which is true error.
If i add my assembly in script's ReferenceAssemblies, error message will display correctly, but i have to add my assembly in every report.
Do you have a good idea?
thanks.
my code like following:
namespace MySoft.Report
{
public class MyTextObject: TextObject
{
}
}
//init
RegisteredObjects.Add(typeof(MyTextObject), "ReportPage", null, "MyText");
Comments
But if any expression in TextObject is error, I found my assembly in ReferenceAssemblies will be lost.
If you have custom control, you have to add its assembly in every report that uses your control. I will try to simplify that in further builds.
help me!
my code:
public class MyButton : Button
{
public MyButton()
{
new Button();
//this.Name= "button1";
}
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap bmp = (Bitmap)Bitmap.FromFile("C:\\alias.ico");
FastReport.Utils.RegisteredObjects.Add(typeof(MyButton), "DialogPage", bmp, "Mybuttontext");
report1.Design();
}
insert MyButton click on dialog form.
problem: "NullReferenceException".
Sorry bad english.
Do you think adding it in later versions , or any ideas how can i achieve this ?
thanks.
Do you think adding it in later versions , or any ideas how can i achieve this ?
i'll use lookupcombo to construct an sql string
In fact, the FastReport's control is just a wrapper for the standard .Net control. It wraps many, but not all, properties of the standard control. If you need some property that is not implemented by the FastReport control, you may access a wrapped standard control in the following way:
?· using the "Control" property, which is of System.Windows.Forms.Control type:
(TextBox1.Control as TextBox).ShortcutsEnabled = false;
?· using the property which has the same name as the control itself, but without the "Control" suffix. For example, the TextBoxControl has got the "TextBox" property, which is of System.Windows.Forms.TextBox type and returns the wrapped TextBox control:
TextBox1.TextBox.ShortcutsEnabled = false;
Help on properties and methods of the controls can be accessed from the MSDN.