我想对接收功率值为2.77的进行特殊显示,代码是按api写的,程序运行无错,但是不起作用,如何解决?
private void Form1_Load(object sender, EventArgs e) { string selectstr = string.Format("SELECT phonenum as '终端号',rssi as '信号强度' FROM dbo.SONDemoSystemTable"); using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["sondemosystem"].ConnectionString)) { con.Open(); SqlDataAdapter adapter = new SqlDataAdapter(selectstr, con); DataSet sourceDataSet = new DataSet(); adapter.Fill(sourceDataSet, "SONDemoSystemTable"); pivotGridControl1.DataSource = sourceDataSet.Tables["SONDemoSystemTable"]; PivotGridField fieldPhone = new PivotGridField("终端号", PivotArea.FilterArea); PivotGridField fieldReceivePower = new PivotGridField("接收功率", PivotArea.FilterArea); pivotGridControl1.Fields.AddRange(new PivotGridField[] {fieldPhone,fieldReceivePower });
PivotGridStyleFormatCondition fCondition = new PivotGridStyleFormatCondition(); fCondition.Field = fieldReceivePower; fCondition.ApplyToCustomTotalCell = false; fCondition.ApplyToGrandTotalCell = false; fCondition.ApplyToTotalCell = false; fCondition.Condition = DevExpress.XtraGrid.FormatConditionEnum.Equal; fCondition.Value1 = 2.77; fCondition.Appearance.BackColor = Color.Red; fCondition.Appearance.Font = new Font(fCondition.Appearance.Font, FontStyle.Bold); fCondition.Appearance.Options.UseBackColor = true; fCondition.Appearance.Options.UseFont = true; pivotGridControl1.FormatConditions.AddRange(new DevExpress.XtraPivotGrid.PivotGridStyleFormatCondition[] { fCondition }); } }
程序没有错误,是运行后的操作失误。