Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. windows datagrid drill down returns relation name [modified]

windows datagrid drill down returns relation name [modified]

Scheduled Pinned Locked Moved Windows Forms
question
9 Posts 4 Posters 4 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Amit Sk Sharma
    wrote on last edited by
    #1

    I am using datagrid control to display drill down data through a dataset. it works fine i.e. displays parent records in required manner (with a plus sign) but on click of plus in place of showing child rows it shows a link with name of relation I defined in dataset. can any one suggest me where I am missing?

    With Thanks & Regards Amit Sk Sharma

    modified on Wednesday, June 29, 2011 6:56 AM

    D 1 Reply Last reply
    0
    • A Amit Sk Sharma

      I am using datagrid control to display drill down data through a dataset. it works fine i.e. displays parent records in required manner (with a plus sign) but on click of plus in place of showing child rows it shows a link with name of relation I defined in dataset. can any one suggest me where I am missing?

      With Thanks & Regards Amit Sk Sharma

      modified on Wednesday, June 29, 2011 6:56 AM

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Considering none of the out-of-the-box datagrid in Windows Form supports drill-down like that, you're going to have to explain what you're using for a grid and/or where it came from. It sounds as though this is some grid you threw together yourself to add drill-down support, and you've obviously got the implementation wrong.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      B A 2 Replies Last reply
      0
      • D Dave Kreskowiak

        Considering none of the out-of-the-box datagrid in Windows Form supports drill-down like that, you're going to have to explain what you're using for a grid and/or where it came from. It sounds as though this is some grid you threw together yourself to add drill-down support, and you've obviously got the implementation wrong.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        Actually, you are incorrect. The DataGridView (and I think the DataGrid in .Net 1.1) does indeed support drilldown through relations, in the manner the OP describes. I have never investigated how to use it effectively, though. EDIT: see answer below. The DataGrid does, the DataGridView does not.

        modified on Wednesday, June 29, 2011 1:14 PM

        L D 2 Replies Last reply
        0
        • D Dave Kreskowiak

          Considering none of the out-of-the-box datagrid in Windows Form supports drill-down like that, you're going to have to explain what you're using for a grid and/or where it came from. It sounds as though this is some grid you threw together yourself to add drill-down support, and you've obviously got the implementation wrong.

          A guide to posting questions on CodeProject[^]
          Dave Kreskowiak

          A Offline
          A Offline
          Amit Sk Sharma
          wrote on last edited by
          #4

          I have more than one tables in my dataset and I have defined relationship between them. sqlDataAdapterClients.Fill(dataSetTimeTracker, "Client"); sqlDataAdapterProjects.Fill(dataSetTimeTracker, "Project"); dataSetTimeTracker.Relations.Add("Intake2Episode", dataSetTimeTracker.Tables["Client"].Columns["ClientID"], dataSetTimeTracker.Tables["Project"].Columns["ClientID"]); dataGrid1.SetDataBinding(dataSetTimeTracker, "Client"); Now my datagrid shows me rows from Client with plus sign and when I click on that plus sign it shows name of relations "Intake2Episode" as a link there in place of respective rows from Project table. wish I could share the screen shot with you. My issue lies here, I am not clear from where (which setting needs to be done)I can get actaul rows in place of relationship.

          With Thanks & Regards Amit Sk Sharma

          D 1 Reply Last reply
          0
          • B BobJanova

            Actually, you are incorrect. The DataGridView (and I think the DataGrid in .Net 1.1) does indeed support drilldown through relations, in the manner the OP describes. I have never investigated how to use it effectively, though. EDIT: see answer below. The DataGrid does, the DataGridView does not.

            modified on Wednesday, June 29, 2011 1:14 PM

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            He's correct. The Windows DataGridView doesn't support this out of the box, nor does the DataGrid. It's quite common on webpages, not in Forms.

            Bastard Programmer from Hell :suss:

            1 Reply Last reply
            0
            • B BobJanova

              Actually, you are incorrect. The DataGridView (and I think the DataGrid in .Net 1.1) does indeed support drilldown through relations, in the manner the OP describes. I have never investigated how to use it effectively, though. EDIT: see answer below. The DataGrid does, the DataGridView does not.

              modified on Wednesday, June 29, 2011 1:14 PM

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Actually, no I'm not incorrect. None of the Windows Forms grids support drilldown. I don't know what you're talking about, but I'm talking about the functionality you see in Access where you click a little "+" symbol and the grid splits, showing you the related records from another table. No, the Windows Forms DataGridxxx controls do not support that.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak

              B 1 Reply Last reply
              0
              • A Amit Sk Sharma

                I have more than one tables in my dataset and I have defined relationship between them. sqlDataAdapterClients.Fill(dataSetTimeTracker, "Client"); sqlDataAdapterProjects.Fill(dataSetTimeTracker, "Project"); dataSetTimeTracker.Relations.Add("Intake2Episode", dataSetTimeTracker.Tables["Client"].Columns["ClientID"], dataSetTimeTracker.Tables["Project"].Columns["ClientID"]); dataGrid1.SetDataBinding(dataSetTimeTracker, "Client"); Now my datagrid shows me rows from Client with plus sign and when I click on that plus sign it shows name of relations "Intake2Episode" as a link there in place of respective rows from Project table. wish I could share the screen shot with you. My issue lies here, I am not clear from where (which setting needs to be done)I can get actaul rows in place of relationship.

                With Thanks & Regards Amit Sk Sharma

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                I had to do some digging to find out which grid you were using. I said you had to say what you were using and you didn't do that. What are you using that old-ass grid for?? Nobody uses it anymore. I see what you're getting at, and what you're seeing is the expected behavior. There is no support in the DataGrid for showing the rows instead of that link. In order to get what you want, you'll either have to roll-your-own version of the DataGridView or use a third party data grid control. Just about every vendors grid supports the drill down functionality.

                A guide to posting questions on CodeProject[^]
                Dave Kreskowiak

                1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Actually, no I'm not incorrect. None of the Windows Forms grids support drilldown. I don't know what you're talking about, but I'm talking about the functionality you see in Access where you click a little "+" symbol and the grid splits, showing you the related records from another table. No, the Windows Forms DataGridxxx controls do not support that.

                  A guide to posting questions on CodeProject[^]
                  Dave Kreskowiak

                  B Offline
                  B Offline
                  BobJanova
                  wrote on last edited by
                  #8

                  I was half right. The DataGrid (but strangely, not the DataGridView) supports drilldown through relations. Here is a test case to demonstrate:

                  using System.Data;
                  using System.Windows.Forms;

                  class Test {
                  DataSet ds;

                  void SetUpData(){
                  	ds = new DataSet();
                  	DataTable dt = new DataTable("lookupTarget");
                  	DataColumn c = new DataColumn("id", typeof(int)); dt.Columns.Add(c);
                  	dt.PrimaryKey = new DataColumn\[\]{ c };
                  	c = new DataColumn("desc", typeof(string)); dt.Columns.Add(c);
                  	ds.Tables.Add(dt);
                  	
                  	dt = new DataTable("main");
                  	c = new DataColumn("id", typeof(int)); dt.Columns.Add(c);
                  	c.AutoIncrement = true;
                  	dt.PrimaryKey = new DataColumn\[\]{ c };
                  	c = new DataColumn("lookup", typeof(int)); dt.Columns.Add(c);
                  	ds.Tables.Add(dt);
                  	
                  	DataRelation dr;
                  	dr = new DataRelation("testRelation", ds.Tables\["main"\].Columns\["lookup"\], ds.Tables\["lookupTarget"\].Columns\["id"\], false);
                  	ds.Relations.Add(dr);
                  	
                  }
                  
                  void PopulateData(){
                  	DataRow row;
                  	
                  	DataTable lookupTarget = ds.Tables\["lookupTarget"\];
                  	DataTable main = ds.Tables\["main"\];
                  	
                  	row = lookupTarget.NewRow();
                  	row\["id"\] = 1;
                  	row\["desc"\] = "Some stuff";
                  	lookupTarget.Rows.Add(row);
                  	
                  	row = lookupTarget.NewRow();
                  	row\["id"\] = 42;
                  	row\["desc"\] = "Don't panic";
                  	lookupTarget.Rows.Add(row);
                  	
                  	
                  	row = main.NewRow();
                  	row\["lookup"\] = 1;
                  	main.Rows.Add(row);
                  
                  	row = main.NewRow();
                  	row\["lookup"\] = 1;
                  	main.Rows.Add(row);
                  
                  	row = main.NewRow();
                  	row\["lookup"\] = 42;
                  	main.Rows.Add(row);
                  }
                  
                  Form Form {
                  	get {
                  		Form f = new Form();
                  		DataGrid dgv = new DataGrid();
                  		dgv.Dock = DockStyle.Fill;
                  		dgv.DataSource = ds.Tables\["main"\];
                  		f.Controls.Add(dgv);
                  		return f;
                  	}
                  }
                  
                  static void Main(){
                  	Test test = new Test();
                  	test.SetUpData();
                  	test.PopulateData();
                  	Application.Run(test.Form);
                  }
                  

                  }

                  Change the variable 'dgv' to a DataGridView and it doesn't work any more. I am not aware of a way to make the expansion do anything other than show a link, though.

                  D 1 Reply Last reply
                  0
                  • B BobJanova

                    I was half right. The DataGrid (but strangely, not the DataGridView) supports drilldown through relations. Here is a test case to demonstrate:

                    using System.Data;
                    using System.Windows.Forms;

                    class Test {
                    DataSet ds;

                    void SetUpData(){
                    	ds = new DataSet();
                    	DataTable dt = new DataTable("lookupTarget");
                    	DataColumn c = new DataColumn("id", typeof(int)); dt.Columns.Add(c);
                    	dt.PrimaryKey = new DataColumn\[\]{ c };
                    	c = new DataColumn("desc", typeof(string)); dt.Columns.Add(c);
                    	ds.Tables.Add(dt);
                    	
                    	dt = new DataTable("main");
                    	c = new DataColumn("id", typeof(int)); dt.Columns.Add(c);
                    	c.AutoIncrement = true;
                    	dt.PrimaryKey = new DataColumn\[\]{ c };
                    	c = new DataColumn("lookup", typeof(int)); dt.Columns.Add(c);
                    	ds.Tables.Add(dt);
                    	
                    	DataRelation dr;
                    	dr = new DataRelation("testRelation", ds.Tables\["main"\].Columns\["lookup"\], ds.Tables\["lookupTarget"\].Columns\["id"\], false);
                    	ds.Relations.Add(dr);
                    	
                    }
                    
                    void PopulateData(){
                    	DataRow row;
                    	
                    	DataTable lookupTarget = ds.Tables\["lookupTarget"\];
                    	DataTable main = ds.Tables\["main"\];
                    	
                    	row = lookupTarget.NewRow();
                    	row\["id"\] = 1;
                    	row\["desc"\] = "Some stuff";
                    	lookupTarget.Rows.Add(row);
                    	
                    	row = lookupTarget.NewRow();
                    	row\["id"\] = 42;
                    	row\["desc"\] = "Don't panic";
                    	lookupTarget.Rows.Add(row);
                    	
                    	
                    	row = main.NewRow();
                    	row\["lookup"\] = 1;
                    	main.Rows.Add(row);
                    
                    	row = main.NewRow();
                    	row\["lookup"\] = 1;
                    	main.Rows.Add(row);
                    
                    	row = main.NewRow();
                    	row\["lookup"\] = 42;
                    	main.Rows.Add(row);
                    }
                    
                    Form Form {
                    	get {
                    		Form f = new Form();
                    		DataGrid dgv = new DataGrid();
                    		dgv.Dock = DockStyle.Fill;
                    		dgv.DataSource = ds.Tables\["main"\];
                    		f.Controls.Add(dgv);
                    		return f;
                    	}
                    }
                    
                    static void Main(){
                    	Test test = new Test();
                    	test.SetUpData();
                    	test.PopulateData();
                    	Application.Run(test.Form);
                    }
                    

                    }

                    Change the variable 'dgv' to a DataGridView and it doesn't work any more. I am not aware of a way to make the expansion do anything other than show a link, though.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    I know. There's also no way to make the DataGrid show the child records. That's why I said what I did. He either has to roll his own or use a third party datagrid to do this.

                    A guide to posting questions on CodeProject[^]
                    Dave Kreskowiak

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups