Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 208
  • Last Modified:

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.  
0
Gary2397
Asked:
Gary2397
2 Solutions
 
tsayCommented:
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
 
PockyMasterCommented:
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
 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now