JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
In the process of setting up my databindings, I've discovered, quite annoyingly, that the databindings can't always be perfect. Case and point, the WebBrowser component. I tried to bind the DocumentText property to a Column in my database and it didn't work at all. (quite depressing).
So instead, since i'm already doing some crazy bindingsource manipulation in my form already, i figured i should just put my updates in there, and for your benefit here is the code of my particular situation...
Now, have no doubt this works perfectly every time, without any errors, But...
The damn Browser component keeps stealing focus from me. I'm scrolling my datagridview, which is bound to bind_Tbls bindingsource, and the position changes. That calls the _positionchanged() event above for the bindingsource, which updates the "embedded" bindingsource, and then checks if the "embedded" source is for the Mailbox. If it is, I open a new document in the browser and the write the html from the current row's body column into the document and all is well, but it appears that when I write into the document, it steals the focus. Is there a way to prevent this, or can anyone think of a better way to display a Database/Table/Column string text of HTML, that wouldn't involve the repetitive re-creating of the browser document.
Personally, I would like a component that just displays HTML without all the over head of web-interfacing that the WebBrowser Component comes with, and I know I could use the ActiveControl.Select method in that event section there, i'm just wondering if there is a better way to come about this that I haven't thought of yet (or are completely unaware of)
Thanks
So instead, since i'm already doing some crazy bindingsource manipulation in my form already, i figured i should just put my updates in there, and for your benefit here is the code of my particular situation...
VB.NET:
Dim bind As BindingSource = sender
If TypeOf bind.DataSource Is BindingSource Then bind = bind.DataSource
If bind IsNot bind_Tbls Then
bind.Position = bind_Tbls.Position
If bind Is bind_MailBox Then 'for the mailbox bind we have
'to some tricky things with the WebBrowser Component
If (bind_Tbls.Position > -1) Then 'if the position is a valid record
If BodyBrowser.Document Is Nothing Then BodyBrowser.DocumentText = "<html></html>"
Dim doc As HtmlDocument = _
BodyBrowser.Document.OpenNew(True) 'create the new browser document
doc.Write(bind(bind.Position)("Body")) 'write the email body text to the html document
SentDateTimePicker.Visible = (Not DirectCast(bind_Tbls.Current, _
RexamShipDataSet.tbl_MailBoxRow).IsSentNull)
ElseIf bind_Tbls.Position = -1 Then
BodyBrowser.Document.OpenNew(True) 'else clear the browser document,
' to keep the form blank on no entries
End If
End If
End If
Now, have no doubt this works perfectly every time, without any errors, But...
The damn Browser component keeps stealing focus from me. I'm scrolling my datagridview, which is bound to bind_Tbls bindingsource, and the position changes. That calls the _positionchanged() event above for the bindingsource, which updates the "embedded" bindingsource, and then checks if the "embedded" source is for the Mailbox. If it is, I open a new document in the browser and the write the html from the current row's body column into the document and all is well, but it appears that when I write into the document, it steals the focus. Is there a way to prevent this, or can anyone think of a better way to display a Database/Table/Column string text of HTML, that wouldn't involve the repetitive re-creating of the browser document.
Personally, I would like a component that just displays HTML without all the over head of web-interfacing that the WebBrowser Component comes with, and I know I could use the ActiveControl.Select method in that event section there, i'm just wondering if there is a better way to come about this that I haven't thought of yet (or are completely unaware of)
Thanks