|
FORUM MESSAGE
|
|
You are reading a General forum message.
Re: Need some help...asap....a bit help for MEMO query
Author: Israel Luengo
Date Posted: 2005-07-30 22:55:25
Hello Eileen, i hope this source code can help you....
suppose you have a Form application, and 3 componentes (TEdit1, TEdit2 and TMemo)
in TEdit1 we will "show" the current character position when you click onto the MEMO component
in TEdit2 we will "show" the number of "column" into the Strings array where is placed the MEMO lines
in MEMO1 we have the memo lines or so.....
this is the OnClick Event.....
----------------------------------------------------------------------------------------------------------------------------------
void __fastcall TForm1::Memo1Click(TObject *Sender)
{
AnsiString CON2; //here we "stored" the copy of each string of Memo-Lines
int length = 0;
int length2 = 0;
int counter = 0; //give us the desired value of String column
int current_selection = 0; //The current character position clicked on Memo component
//here obtain the current position of character into the strings array (position)
Memo1->SelLength = 0;
current_selection = Memo1->SelStart; //get the current position when click
Edit1->Text = current_selection; //and show it on a Edit1 component
//////////////////////////////////////////////////////////////////////////////////
///This is a bit tricky, and don't works fine :(
///but maybe you can get some idea ;))
//First, a loop "walking" the Strings array
for (int i = 0; i <= Memo1->Lines->Count; i++)
{ CON2 += Memo1->Lines->Strings[i].c_str();
length = CON2.Length();
length2 += length;
if(length2 < current_selection)
{
counter++; // if not reached the character selected when you click the MEMO comp.....then the counter goes up
}
else if(length2 >= current_selection)
{ Edit2->Text = counter; //here's the value we're searching...this is..the n� of index on strings array
length = 0; length2 = 0;}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
REPLY TO THIS MESSAGE?
Top
You can post a reply to this General message using the form below:
|
|