2

请帮助我,如何在每列中找到最高数字并将其格式化以使其粗体。

4

1 回答 1

5

请使用此方法。

protected void RadGrid1_PreRender(object sender, EventArgs e)
{
    string[] numericColumns = { "OrderID", "Freight", "Freight1", "Freight2" };
    foreach (string uniqueName in numericColumns)
    {
        int index = -1;
        decimal maxNumber = decimal.MinValue;
        foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
        {
            decimal currentNumber = decimal.Parse(dataItem[uniqueName].Text);
            if (currentNumber > maxNumber)
            {
                maxNumber = currentNumber;
                index = dataItem.ItemIndex;
            }
        }
        if (index >= 0)
        {
            GridTableCell cell = (RadGrid1.Items[index] as GridDataItem)[uniqueName] as GridTableCell;
            cell.BackColor = System.Drawing.Color.LightBlue;
        }
    }
}

希望这对你有用。

于 2012-09-26T04:40:04.387 回答