Filling and Looping an Array

I am displaying text in a tooltip on a datagrid. Depending on the cell that the mouse hovers, I need to display text in the tooltip. For instance:

I hover over a column with package descriptions and display a tooltip with package code.

I have a query that gets package description and package code, among other fields, and fills a dataset.

I am thinking of creating a two-dimensional array. And filling it with the data from the dataset. Does anyone have any code for filling an array with a dataset and looping through the array and retrieve the values.  
Gary2397Asked:
Who is Participating?
 
PockyMasterConnect With a Mentor Commented:
I would recommend using a hashtable instead.
Add items with your key (it's the description i guess in your cases)
and set the object to your package code.

Actually it seems more logical for me to have the code as your column and the description as the tooltips (and in that case you will switch the key and the value in the hashtable as well)

0
 
tsayConnect With a Mentor Commented:
Yeah, something like this:

'
'Adding data from dataset in array
'
Dim arrExample As String(1,1)
Dim drRow as YourDataSet.YourDataTableNameRow

For Each drRow in YourDataSet
'check field for dbnull  
  if not IsDbNull(YourDataSet.YourField) then
    arrExample(0,1) = YourDataSet.YourField.ToString
  End If  
...
Next

'
'Reading data from array
'
for i as integer=0 to 1
  for j as integer=0 to 1
    msgbox(arrExample(i,j).ToString)
  next
next

HTH
0
 
Gary2397Author Commented:
I split the points because tsay gave me a solution, and pockymaster gave me a solution that I think is a better way to accomplish this task.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.