-
Oct 14th, 2012, 07:39 AM
#1
Thread Starter
Frenzied Member
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();
}
-
Oct 14th, 2012, 02:42 PM
#2
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();
}
-
Oct 14th, 2012, 03:53 PM
#3
Thread Starter
Frenzied Member
Re: Populating DatagridView
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();
}
-
Oct 14th, 2012, 11:48 PM
#4
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.
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
|