Filling and Looping an Array

Posted on 2006-05-02
Last Modified: 2010-05-18
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.  
Question by:Gary2397
    LVL 5

    Assisted Solution

    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  

    'Reading data from array
    for i as integer=0 to 1
      for j as integer=0 to 1

    LVL 14

    Accepted Solution

    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)


    Author Comment

    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.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now