我在正确显示列时遇到问题
某些专栏之间存在一些差距
我想附上一张照片,但我需要10个声望点来张贴图片
见下面的图片链接!!
这是我的代码:
private void UpdateProducts()
{
MyPharmacyDataContext db = new MyPharmacyDataContext();
int tabid = Convert.ToInt32(radRibbonBar1.SelectedCommandTab.Name);
var list = from g in db.OutOfStocks
where g.ListID == tabid
select new { g.ID, g.Product.CName, g.Required, g.Product.Price, g.Product.Disscount, g.Product.BuyPrice, g.TotalBuy, Stock = g.Product.Available + "," + g.Product.AvailableMid + "," + g.Product.AvailableSmall,g.Product.Supplier.Title };
if (list.Count() > 0)
{
radGridView1.SummaryRowsBottom.Clear();
radGridView1.Columns.Clear();
radGridView1.Visible = true;
radGridView1.TableElement.TableHeaderHeight = 60;
GridViewTextBoxColumn num = new GridViewTextBoxColumn();
num.MaxWidth = 50;
num.Name = "num";
num.HeaderText = "م";
num.DataType = typeof(int);
radGridView1.Columns.Add(num);
radGridView1.DataSource = list;
radGridView1.Columns[1].IsVisible = false;
radGridView1.Columns[2].Width = 350;
radGridView1.Columns[2].HeaderText = "اسم المنتج";
radGridView1.Columns[2].Name = "Name";
radGridView1.Columns[2].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[3].MaxWidth = 60;
radGridView1.Columns[3].HeaderText = "عدد";
radGridView1.Columns[3].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[3].Name = "Q";
radGridView1.Columns[4].MaxWidth = 90;
radGridView1.Columns[4].HeaderText = "السعر";
radGridView1.Columns[4].Name = "Price";
radGridView1.Columns[4].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[4].FormatString = "{0:G29}";
radGridView1.Columns[5].MaxWidth = 80;
radGridView1.Columns[5].HeaderText = "الخصم";
radGridView1.Columns[5].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[5].FormatString = "{0:G29}";
radGridView1.Columns[6].MaxWidth = 100;
radGridView1.Columns[6].HeaderText = "سعر\nالشراء";
radGridView1.Columns[6].Name = "BuyPice";
radGridView1.Columns[6].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[6].FormatString = "{0:G29}";
radGridView1.Columns[7].MaxWidth = 100;
radGridView1.Columns[7].HeaderText = "اجمالي\nالشراء";
radGridView1.Columns[7].Name = "TotalBuyPice";
radGridView1.Columns[7].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[7].FormatString = "{0:G29}";
radGridView1.Columns[8].MaxWidth = 80;
radGridView1.Columns[8].MinWidth = 80;
radGridView1.Columns[8].Name = "Stock";
radGridView1.Columns[8].HeaderText = "الرصيد";
radGridView1.Columns[8].TextAlignment = ContentAlignment.MiddleCenter;
radGridView1.Columns[9].MaxWidth = 100;
radGridView1.Columns[9].MinWidth = 100;
radGridView1.Columns[9].Name = "Supplier";
radGridView1.Columns[9].HeaderText = "افضل\nمورد";
radGridView1.Columns[9].TextAlignment = ContentAlignment.MiddleCenter;
GridViewCheckBoxColumn checkbox = new GridViewCheckBoxColumn();
checkbox.MaxWidth = 30;
checkbox.HeaderText = "";
checkbox.DataType = typeof(bool);
checkbox.Name = "Ordered";
radGridView1.Columns.Add(checkbox);
var allpro = from g in db.OutOfStocks
where g.ListID == tabid
select g;
foreach (OutOfStock p in allpro)
{
foreach (GridViewRowInfo row in radGridView1.Rows)
{
if ((int)row.Cells[1].Value == p.ID)
{
if (p.Ordered == 'y')
row.Cells["Ordered"].Value = true;
else
row.Cells["Ordered"].Value = false;
}
}
}
GridViewSummaryItem total = new GridViewSummaryItem("Name", "الاجمالي", GridAggregateFunction.Avg);
GridViewSummaryItem price = new GridViewSummaryItem();
price.Name = "Price";
price.AggregateExpression = "(Sum(Q*Price))";
price.FormatString = "{0:G29}";
// GridViewSummaryItem price = new GridViewSummaryItem("Price", "{0}", GridAggregateFunction.Sum);
GridViewSummaryItem buypice = new GridViewSummaryItem("TotalBuyPice", "{0:G29}", GridAggregateFunction.Sum);
GridViewSummaryRowItem summaryRowItem = new GridViewSummaryRowItem(new GridViewSummaryItem[] { total, price, buypice });
radGridView1.SummaryRowsBottom.Add(summaryRowItem);
radGridView1.Focus();
}
else
{
radGridView1.Visible = false;
}
if (radGridView1.Rows.Count() > 0)
radGridView1.ChildRows.Last().IsCurrent = true;
}