Intersoft WebGrid Documentation
WebGridFormatCondition Class
Members  Example  See Also  Send Feedback
ISNet.WebUI.WebGrid Namespace : WebGridFormatCondition Class






Represents the condition or styles that can be defined and applied when the condition is met on WebGridTable object. Known of its rich styles, Intersoft WebGrid.NET WebGridFormatCondition has many settings that can be applied automatically, such as BackColor, ForeColor, FontSize, and so on.

Object Model

WebGridFormatCondition Class

Syntax

Visual Basic (Declaration) 
<PersistenceModeAttribute(PersistenceMode.InnerProperty)>
<DescriptionAttribute()>
<SerializableAttribute()>
Public Class WebGridFormatCondition 
   Inherits ISNet.WebUI.NamedObjectBase
   Implements ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.WebUI.INamedObject 
Visual Basic (Usage)Copy Code
Dim instance As WebGridFormatCondition
C# 
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[DescriptionAttribute()]
[SerializableAttribute()]
public class WebGridFormatCondition : ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.WebUI.INamedObject  
Delphi 
public class WebGridFormatCondition = class(ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.WebUI.INamedObject)
JScript 
PersistenceModeAttribute(PersistenceMode.InnerProperty)
DescriptionAttribute()
SerializableAttribute()
public class WebGridFormatCondition extends ISNet.WebUI.NamedObjectBase implements ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.WebUI.INamedObject 
Managed Extensions for C++ 
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[DescriptionAttribute()]
[SerializableAttribute()]
public __gc class WebGridFormatCondition : public ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.WebUI.INamedObject  
C++/CLI 
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[DescriptionAttribute()]
[SerializableAttribute()]
public ref class WebGridFormatCondition : public ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.WebUI.INamedObject  

Example

The following example shows you how to create WebGridFormatCondition programmatically. In the example, we specify 2 format conditions: Country= UK, TargetObject=Row, FormatStyle=ForeColor:Red; City=Paris, TargetObject=Cell, TargetColumn=City, FormatStyle=Forecolor:Purple
C#Copy Code
private void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
      DataSet ds = new DataSet();
      oleDbDataAdapter1.Fill(ds);
      e.DataSource = ds;
}

private void WebGrid1_PrepareDataBinding(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    if(!IsPostBack)
    {
        WebGrid1.RetrieveStructure();
    
        WebGridFormatCondition wf = new WebGridFormatCondition();
        wf.TargetObject = TargetObjectType.Row;
        wf.FormatStyle.ForeColor = System.Drawing.Color.Red;
        wf.ColumnMember="Country";
        wf.ConditionText="UK";
        wf.Name="FormatCondition1";
        WebGrid1.RootTable.FormatConditions.Add(wf);

        WebGridFormatCondition wf2 = new WebGridFormatCondition();
        wf2.TargetObject = TargetObjectType.Cell;
        wf2.TargetColumnMember = "City";
        wf2.FormatStyle.ForeColor = System.Drawing.Color.Purple;
        wf2.ColumnMember = "City";
        wf2.ConditionText = "Paris";
        wf.Name = "FormatCondition2";
        WebGrid1.RootTable.FormatConditions.Add(wf2);
     }
}

Remarks

WebGridFormatCondition is a feature attached per table that allows you to define the conditions and apply the styles automatically when the condition is met. You can easily define the conditions in WebGrid.NET Designer or you can define them programmatically. The formatting can be applied to either specified TargetColumn or entire row. There are numerous methods you can use to define the criteria, target object, and more.

There are two condition matching mode, the first is a simple mode where you specify a ColumnMember, Operator and ConditionText to match and the second is CustomConditionText where you can specify a filtering against the datamember available in your datasource. The filtering used in CustomConditionText comforts to the ADO.NET expression specification and therefore allow you to match any complex conditions.

When you set Row on the TargetObject, the FormatStyle will be applied to entire row when the condition is met. When set to Cell, you need to specify the TargetColumnMember. In this mode, the FormatStyle will only be applied to TargetColumnMember.

FormatConditions is built on top of automatic style merging architecture, so if there are more than one condition that matched in a single target-object, the FormatStyle will all be applied having the style priority following the order of the format condition. For more information you can read Conditional Formatting.

Inheritance Hierarchy

System.Object
   ISNet.WebUI.WebUIBaseClass
      ISNet.WebUI.NamedObjectBase
         ISNet.WebUI.WebGrid.WebGridFormatCondition

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.