Le 2005-02-01 16:21, Frank Sch�nheit a �crit :

Ah, forgive me: According to the documentation of com.sun.star.form.control.GridControl (which I wrote myself a long time ago, but obviously forgot :), the sequence of values does *not* contain absolute positions, but instead so-called bookmarks. [1] You need to pass them to the "moveToBookmark" of the result set, instead of the "absolute" method.


Yes, it works now ! Here is the snippet, done with Paolo's superb wizard. Hope the attachment goes through. Bernard


<?xml version="1.0"?>

<!--
$RCSfile: index.html,v $

last change: $Revision: $ $Author: $ $Date: $

(c)2003 by the copyright holders listed with the author-tags.
If no explicit copyright holder is mentioned with a certain author,
the author him-/herself is the copyright holder. All rights reserved.

Public Documentation License Notice:

The contents of this Documentation are subject to the
Public Documentation License Version 1.0 (the "License");
you may only use this Documentation if you comply with
the terms of this License. A copy of the License is
available at http://www.openoffice.org/licenses/PDL.html

The Original Documentation can be found in the CVS archives
of openoffice.org at the place specified by RCSfile: in this header.

The Initial Writer(s) of the Original Documentation are listed
with the author-tags below.

The Contributor(s) are listed with the author-tags below
without the marker for being an initial author.

All Rights Reserved.
-->

<snippet language="OOBasic" application="Database">

<keywords>
	<keyword>DataBrowser</keyword>
	<keyword>interface</keyword>
	<keyword>beamer</keyword>
	<keyword>grid</keyword>
	<keyword>selection</keyword>
</keywords>

<authors>
	<author id="BMarcelly" initial="true" email="">Bernard Marcelly</author>
	<author id="" initial="true" email="">Marc Santhoff</author>
	<author id="" initial="true" email="">Frank Sch&#246;nheit</author>
	<author id="" initial="true" email="">Paolo Mantovani</author>
	<author id="sos" initial="true" email="">Fernand</author>
</authors>

<question heading="Call a method from a specific interface">
In Basic, how to call a method offered by a specific interface of an object ?
</question>

<answer>
<p>An object may support the same method name from several interfaces. In this case Basic uses the first method it finds. This snippet shows how to specify which method to use.</p>
<p>Based on Developer&apos;s Guide  chapter 6.2.6.</p>
<listing>
Option Explicit

Sub RowSelectionInDataBrowser
&apos; finds which rows in the DataSourceBrowser are selected by the user
Dim frame1 As Object, frame2 As Object
Dim oModel As Object, oResults As Object
Dim oDoc As Object, oGrid As Object
Dim oDataSourceBrowser as Object
Dim oSelection as Variant, ii As Long

oDoc = thiscomponent
frame1 = oDoc.CurrentController.Frame
frame2 = frame1.findFrame(&quot;_beamer&quot;,4) &apos; get DataBrowser frame
if IsNull(frame2) then
  MsgBox(&quot;Beamer not found !&quot;, 16)
  Exit Sub
end if
oDataSourcebrowser = frame2.Controller
&apos; the DataSourceBrowser object has several getModel methods
&apos; choose getModel from interface com.sun.star.awt.XTabController
&apos; to get the form used by DataSourceBrowser
oModel = oDataSourcebrowser.com_sun_star_awt_XTabController_getModel
&apos; creating a &quot;clone&quot; of the form
oResults = oModel.createResultSet
oGrid = oDataSourceBrowser.CurrentControl
oSelection = oGrid.Selection
if UBound(oSelection) &gt;= 0 then &apos; we get a list of Bookmarks
  For ii= 0 To UBound(oSelection)
    if oResults.moveToBookmark(oSelection(ii)) then
      MsgBox( oResults.Columns(0).String &amp; &quot; : &quot; &amp; oResults.Columns(4).String )
    else
      MsgBox(&quot;Bookmark not found : &quot; &amp; oSelection(ii), 16)
    end if
  Next
else
  MsgBox(&quot;No line selected in the DataBrowser&quot;, 16)
end if
End Sub
</listing>
</answer>

<changelog>
</changelog>

</snippet>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to