How the Cursor move in the Tags of TSrichViewEdit ?
How the Cursor move in the Tags of TSrichViewEdit ?
First,thank your help me!
Now,I find a problem.I want to use the Tags in the TSrichViewEdit .
The user want to used the "Enter" key to move the Cursor.
How I do?
Thank you for your help! I'm very impatient.
Thanks again!
Now,I find a problem.I want to use the Tags in the TSrichViewEdit .
The user want to used the "Enter" key to move the Cursor.
How I do?
Thank you for your help! I'm very impatient.
Thanks again!
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Cusor Move
Sorry! I don't describe it carefully.Sergey Tkachenko wrote:1) How do you want to use tags?
2) Where do you want to move the caret when the user pressed Enter?
My sourcecode is as below.
//-------((
procedure TForm1.FormCreate(Sender: TObject);
var r,c: Integer;
begin
table1 := TRVTableItemInfo.CreateEx(2,14, srv.RichViewEdit.RVData);
table1.BorderWidth := 0;
table1.CellBorderWidth := 0;
table1.CellBorderStyle := rvtbColor;
table1.CellBorderColor := clwhite;
table1.BorderStyle := rvtbColor;
with table1 do begin
Cells[0,12].AddNL('ГЕХпєЕ',0,0);
Cells[1,0].AddNL('РХГы',0,0);
Cells[1,2].AddNL('РФ±р',0,0);
Cells[1,4].AddNL('ДкБд',0,0);
Cells[1,6].AddNL('їЖ±р',0,0);
Cells[1,8].AddNL('ІЎКТ',0,0);
Cells[1,10].AddNL('ґІєЕ',0,0);
Cells[1,12].AddNL('ЧЎФєєЕ',0,0);
//----РґИлTag
Cells[0,13].AddNLTag('xxxx',6,0,Integer(StrNew('eName1')));
Cells[1,1].AddNLTag('xxx',6,0,Integer(StrNew('eName2')));
Cells[1,3].AddNLTag('x',6,0,Integer(StrNew('eName3')));
Cells[1,5].AddNLTag('xx',6,0,Integer(StrNew('eName4')));
Cells[1,7].AddNLTag('xxxx'+#13+'oooooopo',6,0,Integer(StrNew('eName5')));
Cells[1,9].AddNLTag('xx',6,0,Integer(StrNew('eName6')));
Cells[1,11].AddNLTag('xx',6,0,Integer(StrNew('eName7')));
Cells[1,13].AddNLTag('xxx',6,0,Integer(StrNew('eName8')));
end;
srv.RichViewEdit.InsertItem('', table1);
end;
///------))
run the program ,it's as below.
http://www.cnblogs.com/mikalshao/galler ... 94404.html
I hope when the user press "enter" key,the cursor move in the place with gray backgrand.
Please help me !
Thanks!
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Cursor Move
OK! Just it I want.Sergey Tkachenko wrote:Do you want it to move to the NEXT text with gray background?
Like MS Excel moves to the next cell when user presses Enter?
I want to move the Cursor in the gray background.
The best,the user use "->" not use "enter" key.because "Enter" key use to newline.
But I find an other problem.If I don't press "enter" key,I input the word "111" in the tag,I can get the word "111".If I input the word "111" ,then press "enter" key,the gray background have a new line ,I add "222" on the end of "111".I get the tag value again.It also "111".
But it's not I want.I want get the whole string "111222".How I do?
Please help me!Thanks a lot.
so I have two problem.The detail is as below.
1) use direction key move the cursor
2) press "Enter" key ,I also get the whole value "111222"
Thanks
The best,the user use "->" not use "enter" key.because "Enter" key use to newline.
But I find an other problem.If I don't press "enter" key,I input the word "111" in the tag,I can get the word "111".If I input the word "111" ,then press "enter" key,the gray background have a new line ,I add "222" on the end of "111".I get the tag value again.It also "111".
But it's not I want.I want get the whole string "111222".How I do?
Please help me!Thanks a lot.
so I have two problem.The detail is as below.
1) use direction key move the cursor
2) press "Enter" key ,I also get the whole value "111222"
Thanks
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
TSRichViewEdit has the method NextCurItem allowing to select the next item having one of the specified StyleNo. In your case, StyleNo=6.
Enter is processed in OnKeyDown event. Unfortunately, it is forbidden to move from cell to cell in OnKeyDown, so we need using PostMessage to call NextCurItem.
1) Define the constant
2) Add in the interface part of the form:
3) Add in the implementation:
4) Add in srv.OnKeyDown:
Enter is processed in OnKeyDown event. Unfortunately, it is forbidden to move from cell to cell in OnKeyDown, so we need using PostMessage to call NextCurItem.
1) Define the constant
Code: Select all
const
WM_GOTONEXTTEXT = WM_APP+100;
Code: Select all
procedure WMGoToNextText(var Msg: TMessage); message WM_GOTONEXTTEXT;
Code: Select all
procedure TForm1.WMGoToNextText(var Msg: TMessage);
begin
srv.NextCurItem([6]);
end;
Code: Select all
if (Key = VK_RETURN) then begin
PostMessage(Handle, WM_GOTONEXTTEXT, 0, 0);
Key := 0;
end;
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Now, about line breaks in fields.
One item cannot contain a line break inside. Because of this, your line
is incorrect, you need using 2 calls of AddNLTag to add 2 lines.
And when you get values, you can enumerate all items having the same tag, something like this:
One item cannot contain a line break inside. Because of this, your line
Code: Select all
Cells[1,7].AddNLTag('xxxx'+#13+'oooooopo',6,0,Integer(StrNew('eName5')));
And when you get values, you can enumerate all items having the same tag, something like this:
Code: Select all
FieldValue := '';
for i := 0 to RVData.ItemCount-1 do
if StrComp(PChar(RVData.GetItemTag(i), 'eName5') then
FieldValue := FieldValue+RVData.GetItemText(i);
Thank you for your help.Sergey Tkachenko wrote:Now, about line breaks in fields.
One item cannot contain a line break inside. Because of this, your lineis incorrect, you need using 2 calls of AddNLTag to add 2 lines.Code: Select all
Cells[1,7].AddNLTag('xxxx'+#13+'oooooopo',6,0,Integer(StrNew('eName5')));
And when you get values, you can enumerate all items having the same tag, something like this:Code: Select all
FieldValue := ''; for i := 0 to RVData.ItemCount-1 do if StrComp(PChar(RVData.GetItemTag(i), 'eName5') then FieldValue := FieldValue+RVData.GetItemText(i);
I test my program with your method.
My sourcode is as below.
//--------
procedure TForm1.Button1Click(Sender: TObject);
var
FieldValue :string;
i :integer;
begin
FieldValue := '';
for i := 0 to srv.RichViewEdit.RVData.ItemCount-1 do
if Pchar(srv.RichViewEdit.RVData.GetItemTag(i))='eName5' then
FieldValue :=FieldValue+ FieldValue+srv.RichViewEdit.RVData.GetItemText(i);
showmessage(inttostr(i)+'-'+FieldValue);
end;
//--------
I copy your code test directly.
Have two problem.
1) Undeclared identifier:"RVDate"
2)The cursor stop the end of "StrComp(PChar(RVData.GetItemTag(i),".
Debug Message:')' expected but ',' found
so I modify your code as above .
I test the program. I click the button1. The message is "1-".
Please help me!
Thanks
Thank you for your help very much!Sergey Tkachenko wrote:TSRichViewEdit has the method NextCurItem allowing to select the next item having one of the specified StyleNo. In your case, StyleNo=6.
Enter is processed in OnKeyDown event. Unfortunately, it is forbidden to move from cell to cell in OnKeyDown, so we need using PostMessage to call NextCurItem.
1) Define the constant2) Add in the interface part of the form:Code: Select all
const WM_GOTONEXTTEXT = WM_APP+100;
3) Add in the implementation:Code: Select all
procedure WMGoToNextText(var Msg: TMessage); message WM_GOTONEXTTEXT;
4) Add in srv.OnKeyDown:Code: Select all
procedure TForm1.WMGoToNextText(var Msg: TMessage); begin srv.NextCurItem([6]); end;
Code: Select all
if (Key = VK_RETURN) then begin PostMessage(Handle, WM_GOTONEXTTEXT, 0, 0); Key := 0; end;
I think that user need used "Enter" key to new line sometime.
so,I want to use "right" key move the cursor to next tag,use "left" key move the cursor to previous tag.
how I do?
Thanks
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Do you look this problem?srvsxf wrote:Thank you for your help.Sergey Tkachenko wrote:Now, about line breaks in fields.
One item cannot contain a line break inside. Because of this, your lineis incorrect, you need using 2 calls of AddNLTag to add 2 lines.Code: Select all
Cells[1,7].AddNLTag('xxxx'+#13+'oooooopo',6,0,Integer(StrNew('eName5')));
And when you get values, you can enumerate all items having the same tag, something like this:Code: Select all
FieldValue := ''; for i := 0 to RVData.ItemCount-1 do if StrComp(PChar(RVData.GetItemTag(i), 'eName5') then FieldValue := FieldValue+RVData.GetItemText(i);
I test my program with your method.
My sourcode is as below.
//--------
procedure TForm1.Button1Click(Sender: TObject);
var
FieldValue :string;
i :integer;
begin
FieldValue := '';
for i := 0 to srv.RichViewEdit.RVData.ItemCount-1 do
if Pchar(srv.RichViewEdit.RVData.GetItemTag(i))='eName5' then
FieldValue :=FieldValue+ FieldValue+srv.RichViewEdit.RVData.GetItemText(i);
showmessage(inttostr(i)+'-'+FieldValue);
end;
//--------
I copy your code test directly.
Have two problem.
1) Undeclared identifier:"RVDate"
2)The cursor stop the end of "StrComp(PChar(RVData.GetItemTag(i),".
Debug Message:')' expected but ',' found
so I modify your code as above .
I test the program. I click the button1. The message is "1-".
Please help me!
Thanks
I can't also get the value .
Please help me!
Thanks.
-
- Site Admin
- Posts: 17564
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Use this function:
How to use:
Code: Select all
function GetFieldValueFromRVData(RVData: TCustomRVData; const FieldName: String): String;
var i,r,c: Integer;
table: TRVTableItemInfo;
begin
Result := '';
for i := 0 to RVData.ItemCount-1 do
if (RVData.GetItemStyle(i)>=0) and
(StrComp(PChar(RVData.GetItemTag(i)), PChar(FieldName))=0) then
Result := Result + RVData.GetItemText(i)
else if (RVData.GetItemStyle(i)=rvsTable) then begin
Table := TRVTableItemInfo(RVData.GetItem(i));
for r := 0 to table.RowCount-1 do
for c := 0 to table.ColCount-1 do
if Table.Cells[r,c]<>nil then
Result := Result+GetFieldValueFromRVData(table.Cells[r,c].GetRVData, FieldName);
end;
end;
Code: Select all
FieldValue := GetFieldValueFromRVData(srv.RichViewEdit.RVData, 'eName5');
Thank you for your help!Sergey Tkachenko wrote:Use this function:How to use:Code: Select all
function GetFieldValueFromRVData(RVData: TCustomRVData; const FieldName: String): String; var i,r,c: Integer; table: TRVTableItemInfo; begin Result := ''; for i := 0 to RVData.ItemCount-1 do if (RVData.GetItemStyle(i)>=0) and (StrComp(PChar(RVData.GetItemTag(i)), PChar(FieldName))=0) then Result := Result + RVData.GetItemText(i) else if (RVData.GetItemStyle(i)=rvsTable) then begin Table := TRVTableItemInfo(RVData.GetItem(i)); for r := 0 to table.RowCount-1 do for c := 0 to table.ColCount-1 do if Table.Cells[r,c]<>nil then Result := Result+GetFieldValueFromRVData(table.Cells[r,c].GetRVData, FieldName); end; end;
Code: Select all
FieldValue := GetFieldValueFromRVData(srv.RichViewEdit.RVData, 'eName5');
But I 'm sorry that I can't test it successful.
I copy your function to my program.
create a button to show the value of the tag "eName5".
But found the error .
The first image is as below.
http://www.cnblogs.com/mikalshao/galler ... 94695.html
The second is
http://www.cnblogs.com/mikalshao/galler ... 94696.html
The third is
http://www.cnblogs.com/mikalshao/galler ... 94697.html
why?
Please help me.
Thanks
[/img]