Visual Basic .NET Forums    

Go Back   Visual Basic .NET Forums > Components & Controls > Editors

VB.NET Forums Newsletter Signup:
Email address:


Editors GUI components such as masked edit, calculators, up/down controls, calendar, time, color pickers, etc.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-04-2008, 3:28 PM
JaedenRuiner's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2007
Age: 30
Posts: 310
Reputation: 67
JaedenRuiner probably authored a book by nowJaedenRuiner probably authored a book by nowJaedenRuiner probably authored a book by now
Default RichTextBox - NewLine

I do quite a bit of formatting in some of my parsing controls, and mostly it is harmless, since the format strings are constants. the line:
Code:
select * from MyTable;
is no different (intrinsically) from
Code:
select *
from mytable
However, the latter of the two is more appealing to the eyes, so while debugging as well as while reformatting the "typed" commands into the editor, it looks more professional and clean. (I also output the formmatted commands to a debug file, but that is of no concern)

So anyway, there I am, I grab from a RichTextBox the command that was typed, (split on the ; character) and I execute in sequence each command, reformatting them and replacing the old with the new as it executes.
But here is the thing:
Code:
Const SQLSELECT = "SELECT {0}" & vbCrLf & "FROM {1}" & vbCrLf
Now, I could use Environment.NewLine as well, but it too equals #13#10 as the standard MSDOS CR/LF line terminator format. Now enter's the brain dead RichTextBox and it strips the #13 character from the strings, so when I try this:
Code:
RichText.SelectionStart = RichText.Text.IndexOf(MySqlString)
It doesn't work (-1 causing exception).

How can I tell the RichTextBox to not strip the carriage return for each new line? I've tried wordwrap = false, but it still keeps only the 10 not the 13.

Thanks
__________________
Jaeden "Sifo Dyas" al'Raec Ruiner
http://www.wayoftheleaf.net/
Reply With Quote
  #2 (permalink)  
Old 11-06-2008, 6:16 AM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 39
Posts: 4,589
Reputation: 334
jmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shame
Default

I'm not sure why the RTB does that or if there's a way to stop it, but have you considered NOT using CrLf as a line break and just using Lf? Modern Windows handles that gracefully in all cases I've seen.
__________________
Essential: Multiple Forms
101 Samples: 2002 | 2003 | 2005Free Components: WFC | XPCC | ElementsEx | VBPP | ADO.NET/MySQL | VisualStyles | NPlot | SDFTutorials: Home & Learn | Start VB.NET | Learn VB.NETFavourites: MSDN | WinForms.NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz
Reply With Quote
  #3 (permalink)  
Old 11-06-2008, 10:48 AM
JaedenRuiner's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2007
Age: 30
Posts: 310
Reputation: 67
JaedenRuiner probably authored a book by nowJaedenRuiner probably authored a book by nowJaedenRuiner probably authored a book by now
Default

Quote:
Originally Posted by jmcilhinney View Post
I'm not sure why the RTB does that or if there's a way to stop it, but have you considered NOT using CrLf as a line break and just using Lf? Modern Windows handles that gracefully in all cases I've seen.
Not in notepad, which is where I most often edit my SQL for this. I resolved it in a better manner. My SqlParsing engine has a property .SQL which parses when Set, but Builds on Get. My Code was, shall we say, having some delays whenever I would select a different "results tab", it would try to do:
Code:
SqlText.SelectionStart = SqlText.Text.IndexOf (Parser(i).SQL)
SqlText.ScrollToCaret
Well, that would s..l...o...w.. down the refresh because it was recalculating. I've done other searches around the web since I posted this, and it is a recurrent problem with the RTB, which comes to question how to export a MSDOS Cr/Lf Text file from the control, but i resolved the issue by simply utilizing the .Tag element of the individual TabPages. When each command is finished execution an event triggers to set the "status" icon of each tab. When I set the status to success I execute:
Code:
TabPage.Tag = Parser(index).SQL.Replace(vbCr, "")
which then later on TabPage selection:
Code:
SqlText.SelectionStart = SqlText.Text.IndexOf(TabCtrl.SelectedTab.Tag)
SqlText.ScrollToCaret
So, in the end, it is still frustrating that unlike other languages, they did not incorporate a "newlinechar" property within the RTB, but on the whole it is managable, and as well that glitch forced me to rethink how I was selecting the active command in the editor.

Thanks
__________________
Jaeden "Sifo Dyas" al'Raec Ruiner
http://www.wayoftheleaf.net/
Reply With Quote
  #4 (permalink)  
Old 11-06-2008, 7:55 PM
jmcilhinney's Avatar
VB.NET Forum Moderator
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2004
Location: Sydney, Australia
Age: 39
Posts: 4,589
Reputation: 334
jmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shamejmcilhinney puts e.f. hutton to shame
Default

Why exactly are you using a RichTextBox anyway? Are you using syntax highlighting? If not then you may as well just use a TextBox, which won't cull your Cr characters.
__________________
Essential: Multiple Forms
101 Samples: 2002 | 2003 | 2005Free Components: WFC | XPCC | ElementsEx | VBPP | ADO.NET/MySQL | VisualStyles | NPlot | SDFTutorials: Home & Learn | Start VB.NET | Learn VB.NETFavourites: MSDN | WinForms.NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz
Reply With Quote
  #5 (permalink)  
Old 11-07-2008, 11:09 AM
JaedenRuiner's Avatar
VB.NET Forum Master
.NET Framework: .NET 3.5 (VS 2008)
 
Join Date: Aug 2007
Age: 30
Posts: 310
Reputation: 67
JaedenRuiner probably authored a book by nowJaedenRuiner probably authored a book by nowJaedenRuiner probably authored a book by now
Default

Quote:
Originally Posted by jmcilhinney View Post
Why exactly are you using a RichTextBox anyway? Are you using syntax highlighting? If not then you may as well just use a TextBox, which won't cull your Cr characters.
Syntax Highlighting will be in eventually, but at the moment it affords me a bit more control, and a larger memory base for large files.

There were other reasons (can't remember though). I basically was trying to do something with the MultiLine TextBox and it wasn't doing what I wanted, so I switched to a RTB and it did. But that was months ago, so, *shrug*.
__________________
Jaeden "Sifo Dyas" al'Raec Ruiner
http://www.wayoftheleaf.net/
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 3:27 AM.




Click to advertise here

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
For advertising opportunities click here.