Results 1 to 4 of 4

Thread: Populating DatagridView

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Question Populating DatagridView

    hi friends , i have been trying to fill
    datagridView .but i am getting the folloiwng
    error .
    Argument '1': cannot convert from 'string' to 'System.Windows.Forms.DataGridViewColumn' C:\TradingSummary\TradingSummaryStatus\FrmBrands.cs 73 43 TradingSummaryStatus
    Code:
       public void FillBrandMaster(){
                foreach (Brand _brand in _brands)
                    dataGridView1.Columns.Add(_brand.BrandID).ToString();                
    
            }

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    Re: Populating DatagridView

    According to the msdn (http://msdn.microsoft.com/en-us/library/wdzcaz7k.aspx) documentation you should use the constructor with 2 string, columnName and headerText. So it could be:

    Code:
      public void FillBrandMaster(){
                foreach (Brand _brand in _brands)
                    dataGridView1.Columns.Add(_brand.BrandID.ToString() ,_brand.Name).ToString();                
    
            }
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2009
    Location
    Watch Window(Shift+f9)
    Posts
    1,879

    Re: Populating DatagridView

    According to the msdn (http://msdn.microsoft.com/en-us/library/wdzcaz7k.aspx) documentation you should use the constructor with 2 string, columnName and headerText. So it could be:
    but how i will increase row . because we need to blank row in datagridview .and i need to fill using property
    Code:
      public void FillBrandMaster(){
                foreach (Brand _brand in _brands)
                    dataGridView1.Columns.Add(_brand.BrandID.ToString(), _brand.BrandName).ToString();                
    
    
            }

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Populating DatagridView

    How about you actually explain what you're trying to accomplish instead of just posting a bit of code that doesn't work and expecting us to somehow divine the rest? For a start, what is that ToString call for? It does nothing useful so get rid of it.

    As for the rest, what is _brands? Why are you creating a column for each BrandID? What's going in the rows? We cannot read your mind. You have to provide us with the information.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width