as I query a database I assemble a styledText st from a number of styleRuns (aka the sql used and the query results)
I then put that styledText into a TextArea with
TA_Report.StyledText = st
but it takes aaaaaages.
The queries and the making of the styled<Text are quick, it is just populating the textArea which is incredibly slow.
I tried
TA_Report.StyledText.RTFData = st.RTFData
but that is even worse.
After looking around I came across this in the MacOSlib but maybe I’m using it wrongly:
#if TargetCocoa then
dim tv as new NSTextView( TA_Report )
dim ts as NSTextStorage = tv.TextStorage
ts.BeginEditing
TA_Report.StyledText = st
ts.EndEditing
#else
TA_Report.StyledText = st
#endif
So how do you quickly assign a styledText object to a TextArea on MacOS X?
I’ve never noticed any slowdown with populating styled text in this manner, but I don’t know the size of your sample. If you work a lot with styled text, you might want to check out the Formatted Text Control from BKeeney Software. link text
I know you’re not normally interested in a 3rd party plugin solution, Markus, but for the sake of others who may find this post and want a solution (including one that involves a 3rd party plugin), the MBS Win plugin solved the exact same problem for me very quickly. I’m pulling in well over 10,000 characters (not exactly sure how many lines … it’s prose-style, paragraph text including indented bulleted lists) and there is no detectable delay once I hit the button that starts the populating process.
// populate the notes template with the Notes field contents from rsGen record set (caseModel table)
Dim cID As String = rsGen.Field("CaseID").StringValue
Dim rs As RecordSet = db.SQLSelect("SELECT NotesData FROM Notes WHERE CaseID='" + cID + "'")
dim ss As String = rs.Field("NotesData").StringValue
if NOT rs.Field("NotesData").Value.IsNull THEN
for iloop As Integer = 0 to Ubound(oContainers)
if oContainerIndex(iloop) = "nc" then
cntNotes(oContainers(iloop)).TANotes.WinRTFDataMBS = ss
Exit For
end if
next
end if
rsGen.Close // close the record set
OK, Markus … gotta admit it … you just put the biggest smile that’s graced my sorry face all day today ^^
If it wasn’t for Christian’s help (and a lot of it, too!), I’d be echoing that comment (although the MBS examples are very good, the online documentation is often confusing to me … but man, once you figure it out, to Michel’s point, it’s “magic”!)