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. C#
  4. Create Control at Runtime

Create Control at Runtime

Scheduled Pinned Locked Moved C#
graphicsquestion
2 Posts 2 Posters 0 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.
  • M Offline
    M Offline
    Mazdak
    wrote on last edited by
    #1

    I use this code to create DataGrid at runtime but when I call this function nothing appeare on the form.

    		DataGrid filtergrid=new DataGrid();
    
    		filtergrid.Top=300;
    		filtergrid.Height=100;
    		filtergrid.Width=280;
    		filtergrid.Left=0;
    
    		filtergrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
    
    		filtergrid.Visible=true;
    
    		filtergrid.Show();
    
    		filtergrid.DataSource= myDataView.Table;
    

    What I miss here? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
    Wish You Were Here-Pink Floyd-1975

    J 1 Reply Last reply
    0
    • M Mazdak

      I use this code to create DataGrid at runtime but when I call this function nothing appeare on the form.

      		DataGrid filtergrid=new DataGrid();
      
      		filtergrid.Top=300;
      		filtergrid.Height=100;
      		filtergrid.Width=280;
      		filtergrid.Left=0;
      
      		filtergrid.HeaderForeColor = System.Drawing.SystemColors.ControlText;
      
      		filtergrid.Visible=true;
      
      		filtergrid.Show();
      
      		filtergrid.DataSource= myDataView.Table;
      

      What I miss here? Mazy "So,so you think you can tell, Heaven from Hell, Blue skies from pain,... How I wish,how I wish you were here."
      Wish You Were Here-Pink Floyd-1975

      J Offline
      J Offline
      James T Johnson
      wrote on last edited by
      #2

      You need to add the control to its parent's Controls collection. In WinForms and ASP.NET this.Controls.Add( filtergrid ); assuming this is the form or page class that the grid will be added to. James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978

      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