-
October 14th, 2012, 06:46 AM
#1
Filling Property data into DataGridView
hi friends , i have been trying to fill datagridView .but i am getting the folloiwng error .
Error 2 The best overloaded method match for 'System.Windows.Forms.DataGridViewColumnCollection.Add(System.Windows.Forms.DataGridViewColumn)' has some invalid arguments C:\TradingSummary\TradingSummaryStatus\FrmBrands.cs 73 17 TradingSummaryStatus
Error 3 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();
}
-
October 15th, 2012, 07:19 AM
#2
Re: Filling Property data into DataGridView
In your original code, You have the .Tostring in the wrong place. The way you have it, you are trying to ".ToString" the .ADD method of the columns collection of the datagridview. I assume you what to "ToString" the brandID. So change the code to...
Code:
public void FillBrandMaster(){
foreach (Brand _brand in _brands)
dataGridView1.Columns.Add(_brand.BrandID.ToString());
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|