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 8256025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:43:24+00:00 2026-06-08T01:43:24+00:00

I’m extending my question here Dynamically Creating GridView and trying a different approch as

  • 0

I’m extending my question here Dynamically Creating GridView and trying a different approch as suggested, but im stuck again.

I have a table that handles my names and order of key values.

KeyNames:
ID Int primary key
KeyName1 varchar(20)
KeyOrder int
KeyName2 varchar(20)
KeyOrder int
...
KeyNameN varchar(20)
KeyOrder int

These Keys represent the Name and Order of another table to be displayed in a gridview. ie:

 DocumentTable:
 ID int primary key
 PDF_Folder varchar(30)
 Key1value varchar(100)
 Key2value varchar(100)
 ..
 KeyNvalue varchar(100)

So in my gridview the user can decide the column names of the Keys and the value (I might want to called Key1 “description” order 1 and Key2 “Names Mentioned” and order 2.

if Order < 0 then it will not be displayed in the gridview.

Im stuck on how I will create a gridview to display each columns for KeyNValue with the colmn name KeyNameN and the order of KeyOrderN..

  • 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-08T01:43:25+00:00Added an answer on June 8, 2026 at 1:43 am

    You will use the DisplayIndex property of the DataGridViewColumn to set the Order.
    You will use the HeaderText property to set the name.
    I see you have no rows, so the grid will have just one row with many columns.

    So, assuming you have a grid named MyGrid, each column is in a class named MyEntityRecord, you have put all columns in a list and you want to display the data after the user clicks on a button, here is a sample code to be called from the Click Event.

    void ShowCustomGrid(List<MyEntityRecord> aList)
    {
        MyGrid.Columns.Clear();
        MyGrid.Rows.Clear();
        for(int loop=0;loop<aList.Count;loop++)
        {
            MyGrid.Columns.Add(new DataGridViewColumn(new DataGridViewTextBoxCell()));
            MyGrid.Columns[loop].Text=aList[loop].KeyName;
            if(aList[loop].KeyOrder<0) MyGrid.Columns[loop].Visible=false;
        }
        //Now that all columns have been added, change the display index
        for(int loop=0;loop<aList.Count;loop++)
        {
             if(aList[loop].KeyOrder>=0) MyGrid.Columns[loop].DisplayIndex=aList[loop].KeyOrder;
        }
        //Finally, put the values
        MyGrid.Rows.Add();
        for(int loop=0;loop<aList.Count;loop++)
        {
            if(aList[loop].KeyOrder>=0) MyGrid.Rows[0].Cells[loop].Value=aList[loop].KeyValue;
        }
    }
    

    If I understood correctly, this should do what you wanted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has

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.