retrieve highlighted (or selected) Text

Topics: Developer Forum, User Forum
Feb 19, 2008 at 3:40 PM
Edited Feb 19, 2008 at 3:41 PM
is there an equivilant of 'selected text', or 'Highlighted text' in the control? I didn't see anything quite like this option.

I'm building a multi-database variation of Query Analyzer. I want to implement the ability to highlight a section of text and use only that text.

example: if i highlighted line 2 of the following 3 lines, how can I retrieved just that line?

update table a set x='y' where x='z'
select from table a --the line i'm going to higlight
delete table a
Coordinator
Feb 19, 2008 at 5:31 PM
Hey, so was I! Well, nothing ever came about from it, but I still have it for someday...

What you want is Scintilla.Selection.Text
Feb 19, 2008 at 5:46 PM


ChrisRickard wrote:
Hey, so was I! Well, nothing ever came about from it, but I still have it for someday...

What you want is Scintilla.Selection.Text


Hey me three :-) Already have a production version built with Delphi:
http://www.amsoftwaredesign.com

Currently porting everything to c# because of the Delphi Job market (pretty much sucks).

hoping to use ScintillaNet for the editing needs in place of SynEdit.

Later,

Tony
Feb 19, 2008 at 5:57 PM
Chris,
I don't see that option, I only see:
Selection.Alpha
Selection.End
Selection.Mode
Selection.Start

I'm using scintillaNet.dll version 1.0.2626.22303

The query analyzer thing is a pretty regular need. I'm making this puppy optionally lock to dll or corresponding web service, that way i avoid the configuration crap for AS400/Oracle on the client.


Feb 19, 2008 at 6:00 PM

tcaduto wrote:
Hey me three :-) Already have a production version built with Delphi:
http://www.amsoftwaredesign.com


Looked at your analyzer, that's some really nice work!
Coordinator
Feb 19, 2008 at 6:19 PM

keslavi wrote:
Chris,
I don't see that option, I only see:
Selection.Alpha
Selection.End
Selection.Mode
Selection.Start


Selection.Text isn't a designable property, but come to think of it I don't really see a reason why it can't be.
You can still use it from code though.
Feb 19, 2008 at 6:24 PM


keslavi wrote:
Looked at your analyzer, that's some really nice work!


Thanks :-) it's been in constant development since 2004.

Later,

Tony
Coordinator
Feb 19, 2008 at 6:31 PM

Currently porting everything to c# because of the Delphi Job market (pretty much sucks).


In many ways that's too bad. I personally think Delphi is better suited to these kinds of apps than .NET is. Delphi compiles to a native binary and doesn't have the other overhead of the .NET framework. It has nearly identical performance to a c++ app but you can still retain your sanity in working with it.

Also have you decided on a Grid component? I have found GridView (and DataGrid) to be too slow and inflexible to use as a general resultset grid.
Feb 19, 2008 at 6:44 PM

ChrisRickard wrote:

Currently porting everything to c# because of the Delphi Job market (pretty much sucks).


In many ways that's too bad. I personally think Delphi is better suited to these kinds of apps than .NET...

Also have you decided on a Grid component? I have found GridView (and DataGrid) to be too slow and inflexible to use as a general resultset grid.


yeah, MS killed Delphi. I cut my teeth on Turbo Pascal, and used Delphi for a few projects. If your selling a product vs selling the source though it shouldn't matter (in theory...). I also enjoy Ruby, although I'm kinda squirrelled into the dotnet world. Ruby is what C# SHOULD have been!

for the grid, I'm using Infragistics. it's moving decently so far, and has some nice grouping capabilities straight out of the box.
Feb 19, 2008 at 6:48 PM

Selection.Text isn't a designable property, but come to think of it I don't really see a reason why it can't be.
You can still use it from code though.


maybe I'm misunderstanding 'you can still use it from code'... if I have a control called txtSciTe, how would I go about using Selection.Text?
Feb 19, 2008 at 7:23 PM


ChrisRickard wrote:
In many ways that's too bad. I personally think Delphi is better suited to these kinds of apps than .NET is. Delphi compiles to a native binary and doesn't have the other overhead of the .NET framework. It has nearly identical performance to a c++ app but you can still retain your sanity in working with it.

Also have you decided on a Grid component? I have found GridView (and DataGrid) to be too slow and inflexible to use as a general resultset grid.


Totally agree and still love Delph, I am only doing this to gain experience with C# in case I have to get a new day job :-)
The one thing that made me do the C# port was the WeifenLuo.WinFormsUI.Docking library, there is nothing like this for Delphi that I could fnd that made docking MDI so incredibly simple. The other thing was ADO.net allows me to create a generic connection class that would be very difficult to do in Delphi, so far the speed is comparable between the Delphi and C# versions. Delphi's way of Database access is much easier though. I think each has it's advantages and disadvantages and is probably really good to know them both. Going from Delphi to C# has been pretty painless as there is a lot of similarity between the two.

I have found that the Datagridview is really slow on win32, but on XP64bit it's much much faster, they must have done some performance enhancements for the 64bit version of .net.

As far as grids go I am pretty sure I will be going with Developer Express, I have all their Delphi VCL stuff and it's always been top notch and their pricing is reasonable and you can just purchase just the grid if you want.
Feb 19, 2008 at 7:25 PM


keslavi wrote:

Selection.Text isn't a designable property, but come to think of it I don't really see a reason why it can't be.
You can still use it from code though.


maybe I'm misunderstanding 'you can still use it from code'... if I have a control called txtSciTe, how would I go about using Selection.Text?


string selectedtext = txtSciTe.Selection.Text;

Later,

Tony
Feb 19, 2008 at 9:47 PM

tcaduto wrote:

string selectedtext = txtSciTe.Selection.Text;



nope, get the error:
Error 3 'Selection' is not a member of 'Scintilla.ScintillaControl'. C:\Data\Dev\YKK\YKKDB-WS\DataMiner\form\fQuery.vb 50 34 DataMiner

the closest valid i have is:
Selection.Alpha
Selection.End
Selection.Mode
Selection.Start

Chris said
"Selection.Text isn't a designable property, but come to think of it I don't really see a reason why it can't be.
You can still use it from code though."

Thanks for the help, I do appreciate it :)




Coordinator
Feb 19, 2008 at 11:26 PM
It doesn't make sense to me. Perhaps if you could zip up your entire project, including the error'd line
string selectedtext = txtSciTe.Selection.Text

and mail it to rickard234@gmail.com I could take a look.
Feb 20, 2008 at 2:10 PM

ChrisRickard wrote:
It doesn't make sense to me. Perhaps if you could zip up your entire project, including the error'd line
string selectedtext = txtSciTe.Selection.Text

and mail it to rickard234@gmail.com I could take a look.


i sent the file, but found a potential solution, have to check the comparitive values of SelectionStart and SelectionEnd
dim s as string
if txtSciTe.SelectionStart<>txtSciTe.SelectionEnd
s=txtscite.text.substring(txtscite.selectionstart,txtscite.selectionend-txtscite.selectionstart)
else
s=txtscite.text
end if

Thanks for everything!
Coordinator
Feb 20, 2008 at 5:45 PM
OK This makes sense now. You're using the 1x ScintillaNET version. I was assuming you were using the 2.0 version. I'd recommend getting the 2.0 version over on the Release tab. The whole API is written to make it easier to work with Scintilla. For instance

txtSciTe.Selection.Text

vs

dim s as string
if txtSciTe.SelectionStart<>txtSciTe.SelectionEnd
s=txtscite.text.substring(txtscite.selectionstart,txtscite.selectionend-txtscite.selectionstart)
else
s=txtscite.text
end if
Coordinator
Feb 20, 2008 at 5:49 PM
Oops, I partially take the last comment back. In ScintillaNET 1x its actually as easy as
s = txtScite.GetSelectedText()

Feb 20, 2008 at 6:46 PM
okay, thanks!
Sep 13, 2010 at 8:21 AM

scintilla.Selection.Text doesn't work for me, here is what i did:

string a = "text";
CodeBox2.Selection.Start = 0;
CodeBox2.Selection.Length = a.Length;
a = CodeBox2.Selection.Text;
CodeBox2.Select();

it doesn't select the string 'text'.