⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 list and multilist.mb

📁 很多的MAPINFO的常见问题下载后可以学习很有帮助
💻 MB
字号:
'*************************************************************************
'*
'* The following code demonstrates the use of the ReadControlValue()
'* function to identify the items that were selected from a ListBox and
'* MultiListBox.  The return values (selected list item number and item
'* contents) are read into variables - an array variable for the multilist
'* box and a string variable for the list box - so that the return values 
'* will be accessible outside of the Dialog Box's OK Handler.
'*   
'*****************************************************************diallist.mb 

Include "MapBasic.def"
Declare Sub Main
Declare Sub OKButtonHandler
Define x*4
Define y*8
Global list(5) as String		' Holds MultiList and ListBox Items
Global mresult(6) as Smallint			' Holds MultiList Item #'s selected
Global lresult as SmallInt		' Holds ListBox Item # selected

Sub Main

   list(1) = "Monday"			' Populate the List Box Array
   list(2) = "Tuesday"			' In this example, the same array
   list(3) = "Wednesday"			' will be used for the ListBox as
   list(4) = "Thursday"			' well as the MultiListBox
   list(5) = "Friday"

   Dialog 
      Title "Test Dialog"
      Width 25x
      Height 28y

   Control StaticText
      Position 3x, 1y
      Title "ListBox"

   Control ListBox
      Id 5
      Position 3x, 3y
      Title from Variable list

   Control StaticText
      Position 3x, 14y
      Title "MultiList Box" 

   Control MultiListBox
      Id 10
      Position 3x, 16y
      Title from Variable list
   
   Control OKButton	
      Calling OKButtonHandler

   Control CancelButton
			
End sub					

'**************************************************************************
'*
'* This routine determines which items were selected from the ListBox and
'* from the MultiListBox and populates variables with the selected list
'* item number(s) and item contents.
'*
'***************************************************************************

Sub OKButtonHandler	
						
   Dim elem as Integer		
   elem = 1									
   mresult(elem) = ReadControlValue(10)				'Get the first item # from MultiListBox
   Do while mresult(elem) <> 0					'Do While it's not the last item
      Print "MultiListBox Item # " + mresult(elem) +		'Print the item #
     		 " =   " + list(mresult(elem))			'Print the MultiListBox contents
      elem = elem + 1							'Increment item place holder by 1
      mresult(elem) =ReadControlValue(10)				'Get the next item# from MultListBox
   Loop									'End Loop

   lresult = ReadControlValue(5)					'Get the ListBox item #
   If lresult <> 0 then							'Do if an item was selected
      Print "List Box Item # " + lresult + 			'Print the item #
		"       =   " + list(lresult)				'Print the ListBox contents
   End If

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -