如何使用C#中的DataGridView控件
2015-12-31 · 知道合伙人数码行家
知道合伙人数码行家
向TA提问 私信TA
1.先是:
C#中的DataGridView控件使用出错:No row can be added to a DataGridView control that does not have columns
2.后来就可以正常显示数据了:
相关代码:
//DataGridView init
dgvSearchResult.ColumnCount = 13;
//dgvSearchResult.Rows.Add();
//(1)title
dgvSearchResult.Columns[0].HeaderText = "Title";
//(2)seller rating ( based on 1-100% format )
dgvSearchResult.Columns[1].HeaderText = "Seller Rating";
//(3)estimated delivery ( based on 24 hours - 7days format )
dgvSearchResult.Columns[2].HeaderText = "Estimated Delivery";
//(4)gig rating ( based on 1-100% )
dgvSearchResult.Columns[3].HeaderText = "Gig Rating";
//(5)orders in que ( based on 0-9999 format )
dgvSearchResult.Columns[4].HeaderText = "Orders in Queue";
//(6)level of the seller ( 1-3 )
dgvSearchResult.Columns[5].HeaderText = "Seller Level";
//(7)haz video ( yes or no )
dgvSearchResult.Columns[6].HeaderText = "Has Video";
//(8)express gigs (yes or no )
dgvSearchResult.Columns[7].HeaderText = "Is Express Gig";
//(9)country flag ( display county flag )
dgvSearchResult.Columns[8].HeaderText = "Country Flag";
//(10)+ve reviews and -ve reviews ( based on 1-9999 )
dgvSearchResult.Columns[9].HeaderText = "Positive Reviews";
dgvSearchResult.Columns[10].HeaderText = "Negative Reviews";
//(11)top rated seller ( yes or no )
dgvSearchResult.Columns[11].HeaderText = "Is Top Rated Seller";
//(12)gig url
dgvSearchResult.Columns[12].HeaderText = "Gig Url";
和
dgvSearchResult.Rows.Add(
singleGigInfo.title,
singleGigInfo.sellerRating,
singleGigInfo.estimatedDelivery,
singleGigInfo.gigRating,
singleGigInfo.ordersInQueue,
singleGigInfo.sellerLevel,
singleGigInfo.hasVideo,
singleGigInfo.isExpressGig,
singleGigInfo.coutryFlag,
singleGigInfo.positiveReviews,
singleGigInfo.negativeReviews,
singleGigInfo.isTopRatedSeller,
singleGigInfo.gigUrl);
2023-05-10 广告