I have a need to programmatically select a row in a grid control in oobase 3.1.1. I need to actually select the whole row so it is highlighted, not just move the cursor through the records in the underlying result set. Any help would be vastly appreciated. I see there is a .select method, for the grid view controller, but cannot figure out what object it wants (see below).
select
boolean
select( [in] any xSelection )
raises( ::com::sun::lang::IllegalArgumentException );
Description
selects the object represented by xSelection if it is known and selectable in this object.
In other words, what is the form for the argument for the select method of com.sun.star.form.FmXGridControl?
After a lot of research, using xray and debugging, I think select should be looking for just the row number of the record, a long.
However, doing so throws an illegal argument exception, see below. I'm beginning to think it just doesn't work...
Thanks for reading!
[Solved] Select A Row in a Grid Control in a Macro
[Solved] Select A Row in a Grid Control in a Macro
Last edited by jdaylight on Wed Oct 28, 2009 10:51 pm, edited 1 time in total.
jdaylight OOo 3.1.1 XP SP3
-
- Volunteer
- Posts: 283
- Joined: Tue Dec 04, 2007 6:38 pm
- Location: Houston, TX
Re: Select A Row in a Grid Control in a Macro
try something like this:
Code: Select all
Sub cmdTestGrid(Event As Object)
Dim gridModel As Object
Dim gridView As Object
Dim Form As Object
Dim sel(0 to 1)
Form=Event.Source.Model.Parent
'GlobalScope.BasicLibraries.LoadLibrary("MRILib")
gridModel=Form.getByName("TableControl")
sel(0)=Form.getBookMark()
gridView=Form.Parent.Parent.CurrentController.getControl(gridModel)
gridView.Select(sel)
End Sub
Re: Select A Row in a Grid Control in a Macro
Defining the selection as an array, setting the bookmark into the array, and using that array as the argument to the select method in the view controller worked!
Thanks, QuazzieEvil, I've been puzzling over this for days. And thanks for the helpful information that you've provided online.
Thanks, QuazzieEvil, I've been puzzling over this for days. And thanks for the helpful information that you've provided online.
jdaylight OOo 3.1.1 XP SP3