[Solved] Searching in a textbox
Posted: Wed Feb 15, 2012 7:57 pm
Hello
History
Long time ago there was a question on the old OOo forum for selecting a word in a long textbox in a form. My knowledge about the API was not enough to find a good solution. The first problem for me was searching in a textbox and later I could not find a good solution for making a selecting in the textbox. When I had opened the form then the selection did work but this not always when I did it more times again. Now I hope I have a solution for all problems. I did found a property on the text what is called: HideInactiveSelection. The property can also be set direct on the textbox without macro. I did not search on that place for the property but I did search in the document properties. Now I'm happy.
The [Solved] find and highlight text or string in forms is solved with a workaround and I hope this works better.
Not all comments are in English. The reason is I did not know when I started to make this public.
Explanation
I believe this is a good working code. The small example demonstrate only how you can search in a textcontrol. I have stripped as much as possible to show how it is working. The result is a example for one control and the Dutch text in the example. I believe this can be used in a samll form. For me own I use code what makes a list of alle the words in a field. I put this words in a table in which I can search. The list of words is combination of a word and a record.This works for the HSQLDB database and maybe for more.
HideInactiveSelection
When you make your own form then take care you set the property Hide Selection to no. This is aproperty of the textbox and not of the form.
Romke
History
Long time ago there was a question on the old OOo forum for selecting a word in a long textbox in a form. My knowledge about the API was not enough to find a good solution. The first problem for me was searching in a textbox and later I could not find a good solution for making a selecting in the textbox. When I had opened the form then the selection did work but this not always when I did it more times again. Now I hope I have a solution for all problems. I did found a property on the text what is called: HideInactiveSelection. The property can also be set direct on the textbox without macro. I did not search on that place for the property but I did search in the document properties. Now I'm happy.
The [Solved] find and highlight text or string in forms is solved with a workaround and I hope this works better.
Not all comments are in English. The reason is I did not know when I started to make this public.
Explanation
I believe this is a good working code. The small example demonstrate only how you can search in a textcontrol. I have stripped as much as possible to show how it is working. The result is a example for one control and the Dutch text in the example. I believe this can be used in a samll form. For me own I use code what makes a list of alle the words in a field. I put this words in a table in which I can search. The list of words is combination of a word and a record.This works for the HSQLDB database and maybe for more.
HideInactiveSelection
When you make your own form then take care you set the property Hide Selection to no. This is aproperty of the textbox and not of the form.
Romke