Reputation: 58
I have a Form with a TextBox
in it. Every time the text changes i use the TextChanged
Event to create a PDF-file and load it to an AxAcroPDF
-Object in the same Form. This works fine, but then the TextBox
loses focus and for some reason the textBox.Focus()
after loading the file doesn't work.
Has anyone ideas how I can arrange that you can go on typing while refreshing the PDF?
EDIT:
i had another idea, i made a separate thread where i update the PDF and in the TextChanged
-event i only set a flag. But now im getting a strange error
Unable to cast COM object of type 'System.__ComObject' to interface type 'AcroPDFLib.IAcroAXDocShim'.
Upvotes: 1
Views: 6971
Reputation: 73
I could not get .Focus() and .Select() to work so I used Jquery and it works perfectly.
$(document).ready(function () {
setTimeout(function () {
$(".contentWrapper input")[0].focus();
}, 100);
});
Upvotes: 0
Reputation: 58
Im so ashamed of myself, i found a really, really dirty hack, but it works... I did the following:
When i write a text in the MessageBox i rewrite my PDF in the TextChange-Event. In the same method i store the Control that has focus (when calling the LoadFile on the PDF-Object this Control still loses focus). And now the dirty work comes: I implemented a Thread that constantly sets focus to the Control stored in the variable. In the Leave-Event of the TextBox i reset the variable so other controls wont be blocked.
Its a really dirty hack i know, but now i can instantly "edit" a pdf with my own form, which is a nice eyecandy ;)
Thanks for all the help!
Upvotes: 1