The RichTextBox in .net doesn't do what I need- It doesn't let me disable AutoWordSelection (the API is broken), I can't change the default tab space size, I don't think I can rig it to do a line number gutter, and I don't think I can rig it to do syntax highlighting without distrupting the user typing.
That means I have to write a textbox from scratch. That will be a bigger job than the entire rest of my project.
Does anyone know of any tutorials and such about writing a custom textbox in C#/.net?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
There are lots of sysntax highlighting tuts here and at www.codeguru.com[^] but I think they're all in C++. The actual highlighting isn't that big a deal. I've done it in VB with the normal VB rich text box for an SQL editor and that worked great.
As for the gutter, how about a richtextbox in a usercontrol. Size the control so it leaves the correct gap at the left side and draw your own line numbers there. You can get the size of the text and the number of lines down through the text the RTB is displaying etc etc etc, so that isn't that hard.
As for AutoWordSelection, uuummm, see what you mean.
Bog wrote: were you able to do it while the user is typing
Yup. Just disable drawing to the window so none of the results of your selection code is drawn while you're doing it. Then store the actual selection (which will probably just be the current caret location) then run your highlightiong code, changing the selection etc etc etc. Then resore the selection/caret etc and Re-enable drawing to the rich text window.
I handled a couple of cases
1) if the user is just typeing, only highlight the current line. This makes the hightlighting quick.
2) When the RTB gets pasted to, highlight the newly added parts or the whole document.
Have a look at the C++ examples to get a better idea of the process. Failing that, just have a go at it and see how it works.
Well, in the normal way, the property can be edited in a textbox, right?
So, we can change its default UITypeEditor to a TextBox which PasswordChar is * or any char you like, by setting some attributes like EditorAttribute on the property you have.
Hope helps to you.
"System.Data.OleDb.OleDbException : Could not find
To overcome this error i tried doing following things
I went to
location in my windows registery and found following things,
Name Type Data
win32 REG_SZ c:\WINDOWS\System32\msexcl40.dll
then I checked if this "msexcl40.dll" really exist at the path c:\WINDOWS\System32
and it was present there.
Then i uninstalled office2000 from my machine and installed OfficeXP.
Still i am getting the same exception.
Can anybody help me in finding out where i am going wrong or what could be the problem?
As Eric allueded to, you've got to watch out when using objects from other assemblies. Unless you're using an interface or class type shared from the same .dll, you'll run into problems. In other words, the assembly creating the object and the assembly trying to downcast the object must both reference a separate assembly that describes the interface or class to which you are downcasting. (Does that make sense?)