|
|||||||
| TX Text Control .NET Server Please use this forum for TX Text Control .NET Server support only. If you need support for a different product, please use the appropriate forum. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Hi,
I seem to be having an issue with the BrowserTextControl (version 15.1), when I add an image to the header or footer, I get a null refernece exception originating from the txkernel. If I change the code to deactivate the header after inserting the image an exception is not thrown. However, if I reactivate the header then the same exception is thrown. The stack trace does not give any particularly useful information (I have included a screenshot as an attachment). Here is my code: Code:
private void tsbAddImage_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = browserTextControl1.Images.ImportFilters;
DialogResult result = openFileDialog1.ShowDialog();
if (result == DialogResult.OK)
{
TXTextControl.Image img = new TXTextControl.Image(openFileDialog1.FileName, openFileDialog1.FilterIndex);
img.ExportFilterIndex = openFileDialog1.FilterIndex;
img.SaveMode = ImageSaveMode.SaveAsData;
if (activePagePart == ActivePart.HEADER)
{
HeaderFooter hf = browserTextControl1.HeadersAndFooters.GetItem(HeaderFooterType.Header);
hf.Images.Add(img, -1);
hf.Deactivate();
}
else if (activePagePart == ActivePart.FOOTER)
{
HeaderFooter hf = browserTextControl1.HeadersAndFooters.GetItem(HeaderFooterType.Footer);
hf.Images.Add(img, -1);
hf.Deactivate();
}
else
{
browserTextControl1.Images.Add(img, -1);
}
}
}
|
|
#2
|
||||
|
||||
|
Re: NullReferenceException after inserting Image in Header
Hello there,
Although you are using version 15.1, you do not seem to use sections, which have to be used to access header and footers: http://www.textcontrol.com/en_US/sup...ories.page.htm Not sure if that is the cause for your exception as I can not run your code (what is activePagePart?). If you supply simpler code or a working sample, I will gladly take a look at your issue.
__________________
Regards, Gunnar Giffey, TX Text Control [Forum Administrator] |
|
#3
|
|||
|
|||
|
Re: NullReferenceException after inserting Image in Header
Hi,
Just as a general point, is there any special approach which needs to be taken to insert an image into a header (assuming that the header is active and the image is being inserted at the current text position). I am using code along the lines of: Code:
browserTextControl1.Images.Add(img, -1); Thanks Stephen |
|
#4
|
|||
|
|||
|
Re: NullReferenceException after inserting Image in Header
I have made a very simple example for investigation:
Created in VS2008 with .NET v2.0 Designer Code: Standard TXControl Setup (ButtonBar, Rulers, StatusBar) with one ToolStripContainer, containing one ToolstripButton called tsbAddImage. tsbAddImage has a Click event handler tsbAddImage_Click. The form uses the code below: Code:
namespace WordProcessor
{
public partial class BrowserAppControl : UserControl
{
public BrowserAppControl()
{
InitializeComponent();
browserTextControl1.ButtonBar = browserButtonBar1;
browserTextControl1.RulerBar = browserRulerBar1;
browserTextControl1.VerticalRulerBar = browserRulerBar2;
browserTextControl1.StatusBar = browserStatusBar1;
browserTextControl1.ViewMode = TXTextControl.ViewMode.PageView;
browserTextControl1.CreateControl();
}
private void tsbAddImage_Click(object sender, EventArgs e)
{
HeaderFooter header = null;
if (browserTextControl1.Sections.GetItem().HeadersAndFooters.GetItem(HeaderFooterType.Header) != null)
{
header = browserTextControl1.Sections.GetItem().HeadersAndFooters.GetItem(HeaderFooterType.Header);
}
else
{
browserTextControl1.Sections.GetItem().HeadersAndFooters.Add(HeaderFooterType.Header);
header = browserTextControl1.Sections.GetItem().HeadersAndFooters.GetItem(HeaderFooterType.Header);
}
header.Activate();
browserTextControl1.HeaderFooterActivationStyle = HeaderFooterActivationStyle.ActivateClick;
browserTextControl1.HeaderFooterFrameStyle = HeaderFooterFrameStyle.DottedFrame;
TXTextControl.Image img = new TXTextControl.Image();
header.Images.Add(img, -1);
}
}
}
Cheers Stephen |
|
#5
|
||||
|
||||
|
Re: NullReferenceException after inserting Image in Header
Hello Stephen,
Thanks your for your reply. Could you please attach the full project, so I can run that here to debug it? You can simply attach it to your post if you zip up the project folder. Thanks.
__________________
Regards, Gunnar Giffey, TX Text Control [Forum Administrator] |
|
#6
|
|||
|
|||
|
Re: NullReferenceException after inserting Image in Header
Hi Gunnar,
Please find attached an example project. I have removed all of the standard TXControl dlls and associated files from the BrowserBin directory to minimize the file size Thanks Stephen |
|
#7
|
||||
|
||||
|
Re: NullReferenceException after inserting Image in Header
Stephen,
I can run and insert an image using your sample project without any exception. Are you able to reproduce the error on your development machine or client PC?
__________________
Regards, Gunnar Giffey, TX Text Control [Forum Administrator] |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Inserting Image | ShitalP | TX Text Control .NET | 1 | April 24, 2009 13:34:30 |
| Inserting Image in Textcontrol | Gnanaprakash | TX Text Control .NET | 2 | December 16, 2008 13:23:17 |
| Inserting an Image | reezel | TX Text Control .NET | 7 | September 5, 2008 13:25:21 |
| After inserting an image, pb to leave blank lines after that image | sebmay | TX Text Control .NET | 4 | June 16, 2008 15:53:53 |
| Problem Inserting Fixed Image | peals97 | TX Text Control ActiveX | 1 | June 21, 2006 11:46:36 |