-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
EditorPartCollection.xml
382 lines (323 loc) · 37 KB
/
EditorPartCollection.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<Type Name="EditorPartCollection" FullName="System.Web.UI.WebControls.WebParts.EditorPartCollection">
<TypeSignature Language="C#" Value="public sealed class EditorPartCollection : System.Collections.ReadOnlyCollectionBase" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit EditorPartCollection extends System.Collections.ReadOnlyCollectionBase" />
<TypeSignature Language="DocId" Value="T:System.Web.UI.WebControls.WebParts.EditorPartCollection" />
<TypeSignature Language="VB.NET" Value="Public NotInheritable Class EditorPartCollection
Inherits ReadOnlyCollectionBase" />
<TypeSignature Language="F#" Value="type EditorPartCollection = class
 inherit ReadOnlyCollectionBase" />
<TypeSignature Language="C++ CLI" Value="public ref class EditorPartCollection sealed : System::Collections::ReadOnlyCollectionBase" />
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Collections.ReadOnlyCollectionBase</BaseTypeName>
</Base>
<Interfaces />
<Docs>
<summary>Contains a collection of <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls used for editing the properties, layout, appearance, and behavior of <see cref="T:System.Web.UI.WebControls.WebParts.WebPart" /> controls. This class cannot be inherited.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class is a read-only collection of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls, typically used by an <xref:System.Web.UI.WebControls.WebParts.EditorZoneBase> zone to track the set of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls contained by the zone.
When a Web Parts page enters edit mode, and a user selects a control to edit, the editing process begins. The zone creates a new <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object consisting of the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls contained by the zone. At various phases in the editing process, the zone accesses the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object to save or retrieve property values between the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls in the collection and the <xref:System.Web.UI.WebControls.WebParts.WebPart> control currently being edited.
You can create an <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> collection of controls for your own programmatic use if, for example, you need to perform some mass operation on a set of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. Even though the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object is read-only, you can make programmatic changes to the properties of the underlying controls referenced in the collection.
## Examples
The following code example demonstrates several uses of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class. There are four parts to this code example:
- A user control that enables you to change display modes on a Web Parts page.
- A class for a custom <xref:System.Web.UI.WebControls.WebParts.WebPart> control named `TextDisplayWebPart`, which is referenced in the Web page and is edited by the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls.
- A Web page that references the `TextDisplayWebPart` control, contains an <xref:System.Web.UI.WebControls.WebParts.EditorZone> control with several of the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls from the Web Parts control set declared in the zone, and contains some event-driven code to create and manipulate an <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object.
- An explanation of how the code example works when you load it in a browser.
The first part of this code example is the user control that enables users to change display modes on a Web page. For details about display modes and a description of the source code in this control, see [Walkthrough: Changing Display Modes on a Web Parts Page](https://msdn.microsoft.com/library/24e42f74-82dc-4c13-8574-130398985fc0).
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/displaymodecs.ascx" id="Snippet4":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/displaymodevb.ascx" id="Snippet4":::
The second part of the code example is the `TextDisplayWebPart` control. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. For a walkthrough that demonstrates both methods of compiling, see [Walkthrough: Developing and Using a Custom Web Server Control](https://msdn.microsoft.com/library/6d90782a-a1a4-45a6-b2d4-cf6362b83b08).
Note that the control has a property named `ContentText`; this property holds the value that the user enters in the text box. This custom property can be edited when the control is in edit mode, along with the standard <xref:System.Web.UI.WebControls.WebParts.WebPart> control properties.
:::code language="csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/textdisplaywebpart.cs" id="Snippet3":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/textdisplaywebpart.vb" id="Snippet3":::
The third part of the code example is the Web page. Notice that the `<asp:editorzone>` element for the page contains declarations for three <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. Two of these controls become part of a custom <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object that is created when the `Button1_Click` method executes.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/editorpartcollectioncs.aspx" id="Snippet1":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/editorpartcollectionvb.aspx" id="Snippet1":::
When you load the page in a browser, you can switch the page into edit mode by selecting **Edit** in the **Display Mode** drop-down list control. You can click the verbs menu (the downward arrow) in the title bar of the `TextDisplayWebPart` control, and click **Edit** to edit the control. When the editing user interface (UI) is visible, you can see all the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. You click the **Create EditorPartCollection** button to see the effects on the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls that are created by the code that is manipulating the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object. Also, notice that the <xref:System.Web.UI.WebControls.WebParts.PropertyGridEditorPart> control allows you to edit the custom `TextDisplayWebPart.ContentText` property. This is possible because the property is marked with a `WebBrowsable` attribute in the source code for the control. If you update the property value in the editing UI, you must return the page to normal browse mode to see the effect of updating the `TextDisplayWebPart.ContentText` property.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.WebParts.EditorPart" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.EditorPartCollection" /> class.</summary>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public EditorPartCollection ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.EditorPartCollection.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 EditorPartCollection();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<Parameters />
<Docs>
<summary>Initializes an empty new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.EditorPartCollection" /> class.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor initializes an empty instance of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class. This overload of the constructor is used internally by the <xref:System.Web.UI.WebControls.WebParts.EditorZone> class in its <xref:System.Web.UI.WebControls.WebParts.EditorZone.CreateEditorParts%2A> method to create an empty collection object. The zone then creates instances of all the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls declared in the child zone template, and uses an internal method to add them to the collection.
You cannot use this overload of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor to create a new instance of <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> and add <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls to it. You must use one of the other overloads for the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor instead.
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public EditorPartCollection (System.Collections.ICollection editorParts);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Collections.ICollection editorParts) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.EditorPartCollection.#ctor(System.Collections.ICollection)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (editorParts As ICollection)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.WebParts.EditorPartCollection : System.Collections.ICollection -> System.Web.UI.WebControls.WebParts.EditorPartCollection" Usage="new System.Web.UI.WebControls.WebParts.EditorPartCollection editorParts" />
<MemberSignature Language="C++ CLI" Value="public:
 EditorPartCollection(System::Collections::ICollection ^ editorParts);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="editorParts" Type="System.Collections.ICollection" />
</Parameters>
<Docs>
<param name="editorParts">An <see cref="T:System.Collections.ICollection" /> of <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.EditorPartCollection" /> class by passing in an <see cref="T:System.Collections.ICollection" /> collection of <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor initializes an instance of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class and passes in a collection of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. This is one overload of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor that you can use to create a new <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object and add <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls to it.
Even though the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> instance created by the constructor is read-only, you can still access the individual <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls in the collection programmatically and call their properties and methods.
One common scenario for using the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor would be if you want to perform some batch operation on an entire set of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls, such as changing the content, appearance, or position of a related group of them.
Another common scenario for using the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor is developing custom <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls that you want to associate with a server control, so that users can edit custom properties on your control. In this scenario, your server control must implement the <xref:System.Web.UI.WebControls.WebParts.IWebEditable> interface, and as part of that task, it must implement the <xref:System.Web.UI.WebControls.WebParts.IWebEditable.CreateEditorParts%2A> method. In that method, to enable the custom <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls to edit your server control, you must add the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls to an <xref:System.Collections.ICollection> instance, such as an <xref:System.Collections.ArrayList> object. Then you can pass the collection of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls to the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor to create a new <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object, which the <xref:System.Web.UI.WebControls.WebParts.EditorZoneBase> zone uses to set up all the controls and begin the editing process.
## Examples
The following code example demonstrates how to create a custom <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> and, even though the collection is read-only, still perform a batch operation to change the individual <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls in the collection. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class overview.
The code in the `Button1_Click` event creates an <xref:System.Collections.ArrayList> object, adds two of the three <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls in the page to the object, and then creates a new <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object using the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.%23ctor%2A> constructor. It also demonstrates how you can make changes to the underlying <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls, even though the collection is read-only.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/editorpartcollectioncs.aspx" id="Snippet2":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/editorpartcollectionvb.aspx" id="Snippet2":::
You can load the page in a browser and switch the page into edit mode by selecting **Edit** in the **Display Mode** drop-down list control. You can click the verbs menu (the downward arrow) in the title bar of the `TextDisplayWebPart` control, and click **Edit** to edit the control. When the editing user interface (UI) is visible, you can see all the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. You click the **Create EditorPartCollection** button to see the effects on the two <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls that are added to the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object.
]]></format>
</remarks>
<altmember cref="T:System.Web.UI.WebControls.WebParts.IWebEditable" />
<altmember cref="P:System.Web.UI.WebControls.WebParts.EditorZoneBase.EditorParts" />
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public EditorPartCollection (System.Web.UI.WebControls.WebParts.EditorPartCollection existingEditorParts, System.Collections.ICollection editorParts);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Web.UI.WebControls.WebParts.EditorPartCollection existingEditorParts, class System.Collections.ICollection editorParts) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.EditorPartCollection.#ctor(System.Web.UI.WebControls.WebParts.EditorPartCollection,System.Collections.ICollection)" />
<MemberSignature Language="VB.NET" Value="Public Sub New (existingEditorParts As EditorPartCollection, editorParts As ICollection)" />
<MemberSignature Language="F#" Value="new System.Web.UI.WebControls.WebParts.EditorPartCollection : System.Web.UI.WebControls.WebParts.EditorPartCollection * System.Collections.ICollection -> System.Web.UI.WebControls.WebParts.EditorPartCollection" Usage="new System.Web.UI.WebControls.WebParts.EditorPartCollection (existingEditorParts, editorParts)" />
<MemberSignature Language="C++ CLI" Value="public:
 EditorPartCollection(System::Web::UI::WebControls::WebParts::EditorPartCollection ^ existingEditorParts, System::Collections::ICollection ^ editorParts);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="existingEditorParts" Type="System.Web.UI.WebControls.WebParts.EditorPartCollection" />
<Parameter Name="editorParts" Type="System.Collections.ICollection" />
</Parameters>
<Docs>
<param name="existingEditorParts">An <see cref="T:System.Collections.ICollection" /> of existing <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls in a zone.</param>
<param name="editorParts">An <see cref="T:System.Collections.ICollection" /> of <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls not in a zone, but created programmatically.</param>
<summary>Initializes a new instance of the <see cref="T:System.Web.UI.WebControls.WebParts.EditorPartCollection" /> class by passing in an <see cref="T:System.Web.UI.WebControls.WebParts.EditorPartCollection" /> collection of <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls, and an <see cref="T:System.Collections.ICollection" /> collection of additional <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls.</summary>
<remarks>To be added.</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="Contains">
<MemberSignature Language="C#" Value="public bool Contains (System.Web.UI.WebControls.WebParts.EditorPart editorPart);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance bool Contains(class System.Web.UI.WebControls.WebParts.EditorPart editorPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.EditorPartCollection.Contains(System.Web.UI.WebControls.WebParts.EditorPart)" />
<MemberSignature Language="VB.NET" Value="Public Function Contains (editorPart As EditorPart) As Boolean" />
<MemberSignature Language="F#" Value="member this.Contains : System.Web.UI.WebControls.WebParts.EditorPart -> bool" Usage="editorPartCollection.Contains editorPart" />
<MemberSignature Language="C++ CLI" Value="public:
 bool Contains(System::Web::UI::WebControls::WebParts::EditorPart ^ editorPart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="editorPart" Type="System.Web.UI.WebControls.WebParts.EditorPart" />
</Parameters>
<Docs>
<param name="editorPart">The <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> being tested for its status as a member of the collection.</param>
<summary>Returns a value that indicates whether a particular control is in the collection.</summary>
<returns>A Boolean value that indicates whether the <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> is in the collection.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.Contains%2A> method determines whether a specific <xref:System.Web.UI.WebControls.WebParts.EditorPart> control is already in the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object.
## Examples
The following code example demonstrates how to determine whether a particular <xref:System.Web.UI.WebControls.WebParts.EditorPart> control is in an <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class overview.
The code in the `Button1_Click` event does not add the `LayoutEditorPart1` control to the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object when it adds the other controls. To confirm that the `LayoutEditorPart1` control is not in the collection, the code uses the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.Contains%2A> method.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/editorpartcollectioncs.aspx" id="Snippet2":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/editorpartcollectionvb.aspx" id="Snippet2":::
When you load the page in a browser, you can switch the page into edit mode by selecting **Edit** in the **Display Mode** drop-down list control. You can click the verbs menu (the downward arrow) in the title bar of the `TextDisplayWebPart` control, and click **Edit** to edit the control. When the editing user interface (UI) is visible, you can see the all the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. If you click the **Create EditorPartCollection** button, you will notice that the background color of the `LayoutEditorPart1` control is different from the other controls, because it is not part of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object.
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="CopyTo">
<MemberSignature Language="C#" Value="public void CopyTo (System.Web.UI.WebControls.WebParts.EditorPart[] array, int index);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void CopyTo(class System.Web.UI.WebControls.WebParts.EditorPart[] array, int32 index) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.EditorPartCollection.CopyTo(System.Web.UI.WebControls.WebParts.EditorPart[],System.Int32)" />
<MemberSignature Language="VB.NET" Value="Public Sub CopyTo (array As EditorPart(), index As Integer)" />
<MemberSignature Language="F#" Value="member this.CopyTo : System.Web.UI.WebControls.WebParts.EditorPart[] * int -> unit" Usage="editorPartCollection.CopyTo (array, index)" />
<MemberSignature Language="C++ CLI" Value="public:
 void CopyTo(cli::array <System::Web::UI::WebControls::WebParts::EditorPart ^> ^ array, int index);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="array" Type="System.Web.UI.WebControls.WebParts.EditorPart[]" />
<Parameter Name="index" Type="System.Int32" />
</Parameters>
<Docs>
<param name="array">An <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> to contain the copied collection of controls.</param>
<param name="index">The starting point in the array at which to place the collection contents.</param>
<summary>Copies the collection to an array of <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> controls.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.CopyTo%2A> method is useful when you want to create a custom array that can contain the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls in the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object, a subset of those controls, or a superset of those controls.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.CopyTo%2A> method to create a custom array of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class overview.
The code in the `Button1_Click` event creates an array of <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls, adds the `LayoutEditorPart1` control to the array, and then uses the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.CopyTo%2A> method to copy the controls from the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object to the array.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/editorpartcollectioncs.aspx" id="Snippet2":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/editorpartcollectionvb.aspx" id="Snippet2":::
When you load the page in a browser, you can switch the page into edit mode by selecting **Edit** in the **Display Mode** drop-down list control. You can click the verbs menu (the downward arrow) in the title bar of the `TextDisplayWebPart` control, and click **Edit** to edit the control. When the editing user interface (UI) is visible, you can see all the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. If you click the **Create EditorPartCollection** button, you will notice that the titles of all the controls in the custom array are listed near the bottom of the page.
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="Empty">
<MemberSignature Language="C#" Value="public static readonly System.Web.UI.WebControls.WebParts.EditorPartCollection Empty;" />
<MemberSignature Language="ILAsm" Value=".field public static initonly class System.Web.UI.WebControls.WebParts.EditorPartCollection Empty" />
<MemberSignature Language="DocId" Value="F:System.Web.UI.WebControls.WebParts.EditorPartCollection.Empty" />
<MemberSignature Language="VB.NET" Value="Public Shared ReadOnly Empty As EditorPartCollection " />
<MemberSignature Language="F#" Value=" staticval mutable Empty : System.Web.UI.WebControls.WebParts.EditorPartCollection" Usage="System.Web.UI.WebControls.WebParts.EditorPartCollection.Empty" />
<MemberSignature Language="C++ CLI" Value="public: static initonly System::Web::UI::WebControls::WebParts::EditorPartCollection ^ Empty;" />
<MemberType>Field</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.EditorPartCollection</ReturnType>
</ReturnValue>
<Docs>
<summary>References a static, read-only, empty instance of the collection.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
A static, read-only, empty instance of <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> reduces memory usage in cases where you want an empty collection instance to return the proper object type from a method or to compare the instance with another object, but you do not need to add members to the instance.
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="IndexOf">
<MemberSignature Language="C#" Value="public int IndexOf (System.Web.UI.WebControls.WebParts.EditorPart editorPart);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance int32 IndexOf(class System.Web.UI.WebControls.WebParts.EditorPart editorPart) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Web.UI.WebControls.WebParts.EditorPartCollection.IndexOf(System.Web.UI.WebControls.WebParts.EditorPart)" />
<MemberSignature Language="VB.NET" Value="Public Function IndexOf (editorPart As EditorPart) As Integer" />
<MemberSignature Language="F#" Value="member this.IndexOf : System.Web.UI.WebControls.WebParts.EditorPart -> int" Usage="editorPartCollection.IndexOf editorPart" />
<MemberSignature Language="C++ CLI" Value="public:
 int IndexOf(System::Web::UI::WebControls::WebParts::EditorPart ^ editorPart);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Int32</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="editorPart" Type="System.Web.UI.WebControls.WebParts.EditorPart" />
</Parameters>
<Docs>
<param name="editorPart">An <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> that is a member of the collection.</param>
<summary>Returns the position of a particular member of the collection.</summary>
<returns>An integer that corresponds to the index of an <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> control in the collection.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
The <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.IndexOf%2A> method is useful if you have multiple <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls on a Web Parts page, and you need to locate a particular control in the collection.
## Examples
The following code example demonstrates how to use the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.IndexOf%2A> method to locate an <xref:System.Web.UI.WebControls.WebParts.EditorPart> control in an <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object. For the full code required to run the example, see the Example section of the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> class overview.
The code in the `Button1_Click` event creates an <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection> object, and then uses the <xref:System.Web.UI.WebControls.WebParts.EditorPartCollection.IndexOf%2A> method to locate the `PropertyGridEditorPart1` control in the collection, and set its <xref:System.Web.UI.WebControls.WebParts.Part.ChromeType%2A> property.
:::code language="aspx-csharp" source="~/snippets/csharp/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/CS/editorpartcollectioncs.aspx" id="Snippet2":::
:::code language="aspx-vb" source="~/snippets/visualbasic/VS_Snippets_WebNet/WebParts_EditorPartCollection_Overview/VB/editorpartcollectionvb.aspx" id="Snippet2":::
When you load the page in a browser, you can switch the page into edit mode by selecting **Edit** in the **Display Mode** drop-down list control. You can click the verbs menu (the downward arrow) in the title bar of the `TextDisplayWebPart` control, and click **Edit** to edit the control. When the editing user interface (UI) is visible, you can see all the <xref:System.Web.UI.WebControls.WebParts.EditorPart> controls. If you click the **Create EditorPartCollection** button, you will notice that the `PropertyGridEditorPart1` control, which is near the bottom of the page, has a title but no border.
]]></format>
</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
<Member MemberName="Item">
<MemberSignature Language="C#" Value="public System.Web.UI.WebControls.WebParts.EditorPart this[int index] { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Web.UI.WebControls.WebParts.EditorPart Item(int32)" />
<MemberSignature Language="DocId" Value="P:System.Web.UI.WebControls.WebParts.EditorPartCollection.Item(System.Int32)" />
<MemberSignature Language="VB.NET" Value="Default Public ReadOnly Property Item(index As Integer) As EditorPart" />
<MemberSignature Language="F#" Value="member this.Item(int) : System.Web.UI.WebControls.WebParts.EditorPart" Usage="System.Web.UI.WebControls.WebParts.EditorPartCollection.Item" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Web::UI::WebControls::WebParts::EditorPart ^ default[int] { System::Web::UI::WebControls::WebParts::EditorPart ^ get(int index); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Web</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Web.UI.WebControls.WebParts.EditorPart</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="index" Type="System.Int32" />
</Parameters>
<Docs>
<param name="index">The index of a particular <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> in a collection.</param>
<summary>Returns a specific member of the collection according to a unique identifier.</summary>
<value>An <see cref="T:System.Web.UI.WebControls.WebParts.EditorPart" /> at the specified index in the collection.</value>
<remarks>To be added.</remarks>
<related type="Article" href="https://learn.microsoft.com/previous-versions/aspnet/e0s9t4ck(v=vs.100)">ASP.NET Web Parts Controls</related>
</Docs>
</Member>
</Members>
</Type>