Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8833643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:49:46+00:00 2026-06-14T08:49:46+00:00

I need to display data that will be hybrid hard-coded strings and data from

  • 0

I need to display data that will be hybrid “hard-coded” strings and data from a database. Specifically, every even-numbered column contains string values that are NOT from the database, and every odd-numbered column contains data. So column 1, for example, will contain values 1 through 12 from the database, so that the first two columns look something like this (and the same pattern repeats several times):

00:00    BoundVal1
00:15    BoundVal2
. . .
02:45    BoundVal12

Is this possible?

Right now I’m using a TableLayoutPanel for this, but the coding for that is a little pretzly (not a Steely Dan reference).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:49:47+00:00Added an answer on June 14, 2026 at 8:49 am

    I finally got this working, based on code from Mohamed Mansour at http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/ca89a857-6e17-44a7-8cdb-90d64a0a7bbe

    int RowCount = 12; 
    Dictionary<int, string> PlatypusPairs;
    
    . . .
    
    private void button3_Click(object sender, EventArgs e) {
        // Retrieve data as dictionary 
        PlatypusPairs = InterpSchedData.GetAvailableForPlatypusAndDate(oracleConnectionTestForm, 42, DateTime.Today.Date);
        int ColumnCount = 16;
        // Add the needed columns
        for (int i = 0; i < ColumnCount; i++) {
            string colName = string.Format("Column{0}", i + 1);
            dataGridView1.Columns.Add(colName, colName); 
        }
    
        for (int row = 0; row < RowCount; row++) {
            // Save each row as an array
            string[] currentRowContents = new string[ColumnCount];
            // Add each column to the currentColumn
            for (int col = 0; col < ColumnCount; col++) {
                currentRowContents[col] = GetValForCell(row, col);
            }
            // Add the row to the DGV
            dataGridView1.Rows.Add(currentRowContents);
        }
    }
    
    private string GetValForCell(int Row, int Col) {
        string retVal;
    
        if (Col % 2 == 0) {
            retVal = GetTimeStringForCell(Row, Col);
        } else {
            retVal = GetPlatypusStringForCell(Row, Col);
        }
        return retVal;
    }
    
    private string GetTimeStringForCell(int Row, int Col) {
        const int TIME_INCREMENT_STEP = 15;
        var dt = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
        dt = dt.AddMinutes(((Col * (RowCount / 2)) + Row) * TIME_INCREMENT_STEP);
        return dt.ToString("HH:mm");
    }
    
    private string GetPlatypusStringForCell(int Row, int Col) {
        int multiplicand = Col / 2;
        string val = string.Empty;
        int ValToSearchFor = (multiplicand * RowCount) + (Row + 1);
        if (PlatypusPairs.ContainsKey(ValToSearchFor)) {
            PlatypusPairs.TryGetValue(ValToSearchFor, out val);
            if (val.Equals(0)) {
                val = string.Empty;
            }
        }
        return val;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a situation where we need to display data from a database in
I need to build a website where we display data that is refreshed every
I need a List component that will display custom data. I want to extend
I have a master page that needs to display some data from my database.
I need to create a service that will return XML containing data from the
I need to be able to display data that I have in 15 minute
I need to create interface MultiLingual, that allows to display object's data in different
I need to display a real time data from MS SQL 2005. I saw
I have some hierarchical data that I need to display in a series of
I have a UIView that will need to display two UITableViews, but they are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.