Ticket Q201819
Visible to All Users

Columns not dynamically populating

created 16 years ago

Hi,
I've been through the documentation fairly thoroughly and I know this has to be a dumb thing I am missing but…
I am trying to populate the columns of grid at runtime. Very simple…I have a DataSet returned from a function and I am assigning it to the grid control and calling the main view populate columns method. When I run it, all I get is a complete blank in the space where the grid is supposed to be. I know I am doing something dumb but I can't for the life of me figure out what is.
Here is a sample:
I drop a gridcontrol on the form -> gridControl1, it creates it's corresponding gridView1. I change no properties at all.
here is a sample of the method I call to initialize the grid:
private void initializeGridControl()
{
    DataSet myDataSet = LoadSomeDataSet() //this returns a valid dataset with 22 columns and 3 rows of data. I traced this out to verify!
    gridControl1.DataSource = myDataSet.Tables[0];
   gridControl1.MainView.PopulateColumns();
}
Is there another method I can run to populate the actual columns or do I have to instantiate each one?
Help…I'm tired.
Thanks,
-m

Comments (2)

    I am stupid…I was referencing the wrong grid. Don't ask.
    Now the code is working as it should however…now the real question:
    I am returning a dataset with 2 tables that I have setup the relationships for (master-detail). It's pretty straight forward, however when I assign the main gridcontrol.DataSource = myDataSet and then call the gridcontrol.MainView.PopulateColumns() method, it doesn't build the columns on either master or detail.
    When I set the gridcontrol.DataSource = myDataSet.Tables[0] and then call the PopulateColumns() method, it builds all the columns in the Table[0] AND creates the 2nd level but creates the same column headings for that grid as well.
    Any ideas of what to look for?
    Thanks…again.
    -m

    DevExpress Support Team 16 years ago

      Hi Mark,
      Thank you for the message. I've created a sample for you, and it works as expected here. Please make sure that the level name of the detail view is the same as the relation name of two tables (a master and detail ones). Please modify my sample to recreate the issue.
      You can find useful information about master-detail mode in the following help topics: Master-Detail overview and Master-Detail: DataTable Use.
      Thanks,
      Svetlana

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.