ehxz 发表于 2007-6-26 12:11:44

[转帖] 如何获得单击 Crosstab DataWindow 某域的值

<table cellspacing="0" cellpadding="0" width="95%" align="center" border="0"><center><tbody><tr><td height="22">&nbsp;</td><td width="100%" height="22"><div align="left"><p align="center"><b>如何获得单击 Crosstab DataWindow 某域的值</b>
                                                        </p></div></td><td height="22">&nbsp;</td></tr><tr><td colspan="3">  </td></tr><tr><td height="560">&nbsp;</td><td width="100%"><div align="left"></div><p align="left">  A crosstab DataWindow is a unique type of DataWindow. When it is built in the DataWindow painter, it is comprised of one row and one column. The remaining columns are dynamically created at runtime. This prevents the use of many of the functions normally used to obtain the value of a clicked item.</p><p align="left">  At runtime, all columns have the same name as the column that was created in the DataWindow painter. The distinguishing difference in the column name is the suffix assigned to the column name. The column names take the form of:</p><p align="left">  columnname_columnnumber~trownumber (row and column numbers are separated by a tab character and the column number is separated from the column name by an underscore character " _ ")</p><p align="left">  The column number is relative to original column that was built with the DataWindow. The original column does not have a column number using the above notation. As an example a column number of two (2) would indicate that the column is the second column to the right of the original column.</p><p align="left">  If you need the value of any of the detail columns they can not be obtained since the column name is the same and the column number must be parsed from a string. The only argument that can be used is the row argument of the clicked event. This will correctly return the row of the detail item clicked.</p><p align="left">  Obtaining the correct column requires the use of the GetObjectAtPointer() function. This will return the column information in the form of:</p><p align="left">  columnname_columnnumber~trownumber</p><p align="left">  The column number has to be parsed from this value and used with the row number to obtain the data for the clicked item. With the row/column combination, we can use a GetItemNumber (or whatever GetItem is needed) in the form of:</p><p align="left">  GetItemNumber( row, column )</p><p align="left">  The column number MUST be used since all the columns have the same name.</p><p align="left">  Below is the example code used to obtain the value of a clicked item in a crosstab DataWindow. Each line of code has a number and will be explained using these numbers as reference</p><blockquote><p align="left"><font color="#006443">1&nbsp;&nbsp;&nbsp; string ls_detail, ls_name, ls_col<br/>2&nbsp;&nbsp;&nbsp; int li_pos, li_len, li_row, li_col<br/>3&nbsp;&nbsp;&nbsp; if left(getbandatpointer(),6) &lt;&gt; "detail" then return<br/>4&nbsp;&nbsp;&nbsp; ls_detail = getobjectatpointer()<br/>5&nbsp;&nbsp;&nbsp; ls_name = Object.#2.Name<br/>6&nbsp;&nbsp;&nbsp; if left(ls_detail,len(ls_name)) &lt;&gt; ls_name then return<br/>7&nbsp;&nbsp;&nbsp; li_row = row<br/>8&nbsp;&nbsp;&nbsp; li_len = len(ls_detail)<br/>9&nbsp;&nbsp;&nbsp; ls_col = right(ls_detail, li_len - len(ls_name))<br/>10&nbsp;&nbsp; if left(ls_col,1) &lt;&gt; "_" then)<br/>11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; li_col = 2<br/>12&nbsp;&nbsp; else<br/>13&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; li_pos = pos(ls_col,"~t")<br/>14&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; li_col = integer(mid(ls_col,2,li_pos - 1) ) + 2<br/>15&nbsp;&nbsp; end if<br/>16&nbsp;&nbsp; parent.title = string(getitemnumber(li_row,li_col))</font></p></blockquote><p align="left">  Line 1 and 2 are variables used for the process</p><p align="left">  Line 3 - Get the band the user clicked in. if it is outside the detail area then return</p><p align="left">  Line 4 - Get the column information for the clicked item</p><p align="left">  Line 5 - Get the name of the column from the column number. We have to use column #2 in a crosstab since column number 1 is not in the detail area we need</p><p align="left">  Line 6 - compare the column name from the column information from line 4 with the column name of the columns in the detail area we need. If they do not match, that means the user clicked in column 1, which is outside the detail area we need. This is needed since the GetBandAtPointer() will still return "detail" for any clicks in column one.</p><p align="left">  Line 7 - Get the row of the clicked item</p><p align="left">  Line 8 - Get the length of the column detail information obtained in line 4. This will be needed for parsing the column number from the detail information.</p><p align="left">  Line 9 - get everything to the right of the column name.</p><p align="left">  Line 10 and 11 - check for an "_" underscore. If there is not one, then we are in the first column of the detail area, which is really column 2.</p><p align="left">  Line 13 - look for the tab character ( ~t ). The column number is between the underscore and the tab character.</p><p align="left">  Line 14 - get the column number</p><p align="left">  Line 16 - this is to display the value of the clicked item in the title bar of the window. (for demo purposes only). You will use the return from the GetItem for your value.<br/>&iexcl;&iexcl;</p><p align="left">  The above code can be copied into the clicked/doubleclicked event of a DataWindow control.</p></td><td height="560"><p>&nbsp;</p><p>&nbsp;</p></td></tr><tr><td>&nbsp;</td><td width="100%"> </td><td>&nbsp;</td></tr></tbody></center></table>

lovelyni 发表于 2007-12-19 22:10:20

看看就觉得好难啊,

lovelyni 发表于 2007-12-19 22:10:47

哎~~~~~自己能力有限啊
页: [1]
查看完整版本: [转帖] 如何获得单击 Crosstab DataWindow 某域的值

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com