Style.CopyFrom(Style) 方法

定義

將指定的 Style 的樣式屬性複製到呼叫這個方法的 Style 類別的執行個體中。Duplicates the style properties of the specified Style into the instance of the Style class that this method is called from.

public:
 virtual void CopyFrom(System::Web::UI::WebControls::Style ^ s);
public virtual void CopyFrom (System.Web.UI.WebControls.Style s);
abstract member CopyFrom : System.Web.UI.WebControls.Style -> unit
override this.CopyFrom : System.Web.UI.WebControls.Style -> unit
Public Overridable Sub CopyFrom (s As Style)

參數

s
Style

Style,表示要複製的樣式。A Style that represents the style to copy.

例外狀況

備註

使用方法,即可將指定Style之的樣式屬性,複製Style到這個方法呼叫來源的類別實例。 CopyFromUse the CopyFrom method to duplicate the style properties of the specified Style into the instance of the Style class that this method is called from.

當使用RegisterStyle註冊樣式,然後使用Style.CopyFrom(Style)進行複製時,只有CssClass屬性會複製到目的地,而不是所有個別的屬性。When a style is registered using RegisterStyle, and then copied using Style.CopyFrom(Style), only the CssClass property is copied to the destination, not all the individual properties. 如果您接著複製或檢查目的地樣式的屬性,這可能會導致非預期的結果。This could lead to unexpected results if you then copy or examine the properties of the destination style. 例如,如果您使用FontInfo.CopyFrom(FontInfo) Font從已註冊的的屬性Style複製字型資訊,就不會從樣式取得字型的個別設定。For example, if you are using FontInfo.CopyFrom(FontInfo) to copy font information from the Font property of a Style that is registered, you will not get the individual settings of the font from the style.

警告

所有屬性(包括已在Style類別的目前實例中設定的內容)都會由s參數所Style指定之中的相關聯屬性所取代。All properties, including those that have been set in the current instance of the Style class, will be replaced by the associated property in the Style specified by the s parameter.

適用於

另請參閱