GridTableStylesCollection Osztály
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Figyelemfelhívás
DataGrid is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use DataGridView instead.
A vezérlőelem objektumgyűjteményét DataGridTableStyleDataGrid jelöli.
public ref class GridTableStylesCollection : System::Windows::Forms::BaseCollection, System::Collections::IList
[System.ComponentModel.ListBindable(false)]
public class GridTableStylesCollection : System.Windows.Forms.BaseCollection, System.Collections.IList
[System.ComponentModel.ListBindable(false)]
[System.ComponentModel.Browsable(false)]
[System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]
public class GridTableStylesCollection : System.Windows.Forms.BaseCollection, System.Collections.IList
[<System.ComponentModel.ListBindable(false)>]
type GridTableStylesCollection = class
inherit BaseCollection
interface IList
interface ICollection
interface IEnumerable
[<System.ComponentModel.ListBindable(false)>]
[<System.ComponentModel.Browsable(false)>]
[<System.Obsolete("`DataGrid` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `DataGridView` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]
type GridTableStylesCollection = class
inherit BaseCollection
interface IList
interface ICollection
interface IEnumerable
Public Class GridTableStylesCollection
Inherits BaseCollection
Implements IList
- Öröklődés
- Attribútumok
- Megvalósítás
Példák
Az alábbi példakód két DataGridTableStyle objektumot hoz létre, és hozzáadja mindegyiket egy GridTableStylesCollectionTableStylesDataGrid vezérlőelem tulajdonsága által visszaadotthoz.
void AddCustomDataTableStyle()
{
DataGridTableStyle^ ts1 = gcnew DataGridTableStyle;
ts1->MappingName = "Customers";
// Set other properties.
ts1->AlternatingBackColor = Color::LightGray;
/* Add a GridColumnStyle and set its MappingName
to the name of a DataColumn in the DataTable.
Set the HeaderText and Width properties. */
DataGridColumnStyle^ boolCol = gcnew DataGridBoolColumn;
boolCol->MappingName = "Current";
boolCol->HeaderText = "IsCurrent Customer";
boolCol->Width = 150;
ts1->GridColumnStyles->Add( boolCol );
// Add a second column style.
DataGridColumnStyle^ TextCol = gcnew DataGridTextBoxColumn;
TextCol->MappingName = "custName";
TextCol->HeaderText = "Customer Name";
TextCol->Width = 250;
ts1->GridColumnStyles->Add( TextCol );
// Create the second table style with columns.
DataGridTableStyle^ ts2 = gcnew DataGridTableStyle;
ts2->MappingName = "Orders";
// Set other properties.
ts2->AlternatingBackColor = Color::LightBlue;
// Create new ColumnStyle objects.
DataGridColumnStyle^ cOrderDate = gcnew DataGridTextBoxColumn;
cOrderDate->MappingName = "OrderDate";
cOrderDate->HeaderText = "Order Date";
cOrderDate->Width = 100;
ts2->GridColumnStyles->Add( cOrderDate );
/*Use a PropertyDescriptor to create a formatted
column. First get the PropertyDescriptorCollection
for the data source and data member. */
System::ComponentModel::PropertyDescriptorCollection^ pcol = this->
BindingContext[myDataSet, "Customers::custToOrders"]->
GetItemProperties();
/* Create a formatted column using a PropertyDescriptor.
The formatting character S"c" specifies a currency format. */
DataGridColumnStyle^ csOrderAmount =
gcnew DataGridTextBoxColumn( pcol[ "OrderAmount" ],"c",true );
csOrderAmount->MappingName = "OrderAmount";
csOrderAmount->HeaderText = "Total";
csOrderAmount->Width = 100;
ts2->GridColumnStyles->Add( csOrderAmount );
/* Add the DataGridTableStyle instances to
the GridTableStylesCollection. */
myDataGrid->TableStyles->Add( ts1 );
myDataGrid->TableStyles->Add( ts2 );
}
private void AddCustomDataTableStyle(){
DataGridTableStyle ts1 = new DataGridTableStyle();
ts1.MappingName = "Customers";
// Set other properties.
ts1.AlternatingBackColor = Color.LightGray;
/* Add a GridColumnStyle and set its MappingName
to the name of a DataColumn in the DataTable.
Set the HeaderText and Width properties. */
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Current";
boolCol.HeaderText = "IsCurrent Customer";
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
// Add a second column style.
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
TextCol.MappingName = "custName";
TextCol.HeaderText = "Customer Name";
TextCol.Width = 250;
ts1.GridColumnStyles.Add(TextCol);
// Create the second table style with columns.
DataGridTableStyle ts2 = new DataGridTableStyle();
ts2.MappingName = "Orders";
// Set other properties.
ts2.AlternatingBackColor = Color.LightBlue;
// Create new ColumnStyle objects.
DataGridColumnStyle cOrderDate =
new DataGridTextBoxColumn();
cOrderDate.MappingName = "OrderDate";
cOrderDate.HeaderText = "Order Date";
cOrderDate.Width = 100;
ts2.GridColumnStyles.Add(cOrderDate);
/*Use a PropertyDescriptor to create a formatted
column. First get the PropertyDescriptorCollection
for the data source and data member. */
System.ComponentModel.PropertyDescriptorCollection pcol =
this.BindingContext[myDataSet, "Customers.custToOrders"]
.GetItemProperties();
/* Create a formatted column using a PropertyDescriptor.
The formatting character "c" specifies a currency format. */
DataGridColumnStyle csOrderAmount =
new DataGridTextBoxColumn(pcol["OrderAmount"], "c", true);
csOrderAmount.MappingName = "OrderAmount";
csOrderAmount.HeaderText = "Total";
csOrderAmount.Width = 100;
ts2.GridColumnStyles.Add(csOrderAmount);
/* Add the DataGridTableStyle instances to
the GridTableStylesCollection. */
myDataGrid.TableStyles.Add(ts1);
myDataGrid.TableStyles.Add(ts2);
}
Private Sub AddCustomDataTableStyle()
Dim ts1 As New DataGridTableStyle()
ts1.MappingName = "Customers"
' Set other properties.
ts1.AlternatingBackColor = Color.LightGray
' Add a GridColumnStyle and set its MappingName
' to the name of a DataColumn in the DataTable.
' Set the HeaderText and Width properties.
Dim boolCol As New DataGridBoolColumn()
boolCol.MappingName = "Current"
boolCol.HeaderText = "IsCurrent Customer"
boolCol.Width = 150
ts1.GridColumnStyles.Add(boolCol)
' Add a second column style.
Dim TextCol As New DataGridTextBoxColumn()
TextCol.MappingName = "custName"
TextCol.HeaderText = "Customer Name"
TextCol.Width = 250
ts1.GridColumnStyles.Add(TextCol)
' Create the second table style with columns.
Dim ts2 As New DataGridTableStyle()
ts2.MappingName = "Orders"
' Set other properties.
ts2.AlternatingBackColor = Color.LightBlue
' Create new ColumnStyle objects.
Dim cOrderDate As New DataGridTextBoxColumn()
cOrderDate.MappingName = "OrderDate"
cOrderDate.HeaderText = "Order Date"
cOrderDate.Width = 100
ts2.GridColumnStyles.Add(cOrderDate)
' Use a PropertyDescriptor to create a formatted
' column. First get the PropertyDescriptorCollection
' for the data source and data member.
Dim pcol As System.ComponentModel.PropertyDescriptorCollection = _
Me.BindingContext(myDataSet, "Customers.custToOrders"). _
GetItemProperties()
' Create a formatted column using a PropertyDescriptor.
' The formatting character "c" specifies a currency format. */
Dim csOrderAmount As _
New DataGridTextBoxColumn(pcol("OrderAmount"), "c", True)
csOrderAmount.MappingName = "OrderAmount"
csOrderAmount.HeaderText = "Total"
csOrderAmount.Width = 100
ts2.GridColumnStyles.Add(csOrderAmount)
' Add the DataGridTableStyle instances to
' the GridTableStylesCollection.
myDataGrid.TableStyles.Add(ts1)
myDataGrid.TableStyles.Add(ts2)
End Sub
Megjegyzések
A GridTableStylesCollection vezérlő olyan objektumokat tartalmazDataGridTableStyle, amelyek lehetővé teszik, hogy a DataGrid vezérlő testre szabott rácsstílust jelenítsen meg az DataTableegyes DataSet objektumokban.
DataGrid A vezérlőelemen a tulajdonság TableStylesa GridTableStylesCollection .
Alapértelmezés szerint a GridTableStylesCollection nem tartalmaz DataGridTableStyle objektumokat. Ehelyett az egyes táblákat a DataGrid szín, a szélesség és a formázás alapértelmezett beállításaival jeleníti meg. Az egyes táblák összes oszlopa megjelenik. Amikor hozzáad egy DataGridTableStyle gyűjteményt, a DataGrid rendszer MappingName meghatározza, hogy melyik objektum látja el az adatokat a rácshoz. Ha például az adatforrás DataSet három objektumot tartalmaz, akkor az DataTable egyik objektumnak meg kell egyeznie MappingNameTableName. Ha az MappingName értékek egyikével TableName sem egyeznek meg, a rendszer az alapértelmezett beállításokat használja az egyes táblák adatainak megjelenítéséhez, és a DataGridTableStyle beállítások figyelmen kívül lesznek hagyva.
Figyelmeztetés
Mindig hozzon létre DataGridColumnStyle objektumokat, és vegye fel őket az GridColumnStylesCollection objektumba, mielőtt objektumokat ad DataGridTableStyle a GridTableStylesCollection. Ha egy üres, érvényes DataGridTableStyle értékkel rendelkező értéket MappingName ad hozzá a gyűjteményhez, DataGridColumnStyle a rendszer automatikusan létrehozza az objektumokat. Következésképpen kivétel jelenik meg, ha ismétlődő értékekkel DataGridColumnStyle rendelkező új MappingName objektumokat próbál hozzáadni a GridColumnStylesCollection. Másik lehetőségként törölje a GridColumnStylesCollection metódus használatát Clear .
Tulajdonságok
| Name | Description |
|---|---|
| Count |
Elavult.
Lekéri a gyűjtemény elemeinek teljes számát. (Öröklődés forrása BaseCollection) |
| IsReadOnly |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a gyűjtemény írásvédett-e. (Öröklődés forrása BaseCollection) |
| IsSynchronized |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a ICollection hozzáférés szinkronizálva van-e. (Öröklődés forrása BaseCollection) |
| Item[Int32] |
Elavult.
Lekéri az DataGridTableStyle index által megadott értéket. |
| Item[String] |
Elavult.
Lekéri a DataGridTableStyle megadott nevet. |
| List |
Elavult.
Lekéri a mögöttes listát. |
| List |
Elavult.
Lekéri a példányban BaseCollection található elemek listáját. (Öröklődés forrása BaseCollection) |
| SyncRoot |
Elavult.
Lekéri az objektumot, amely a hozzáférés szinkronizálására használható.BaseCollection (Öröklődés forrása BaseCollection) |
Metódusok
| Name | Description |
|---|---|
| Add(DataGridTableStyle) |
Elavult.
Hozzáad egy DataGridTableStyle elemet ehhez a gyűjteményhez. |
| AddRange(DataGridTableStyle[]) |
Elavult.
Táblázatstílusokat tartalmazó tömböt ad hozzá a gyűjteményhez. |
| Clear() |
Elavult.
Törli a gyűjteményt. |
| Contains(DataGridTableStyle) |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a GridTableStylesCollection megadott DataGridTableStyleértéket tartalmazza-e. |
| Contains(String) |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a GridTableStylesCollection megadott név tartalmazza-e a DataGridTableStyle megadott értéket. |
| CopyTo(Array, Int32) |
Elavult.
Másolja az aktuális egydimenziós Array elemeket a megadott egydimenziósra Array a megadott célindextől Array kezdve. (Öröklődés forrása BaseCollection) |
| CreateObjRef(Type) |
Elavult.
Létrehoz egy objektumot, amely tartalmazza a távoli objektumokkal való kommunikációhoz használt proxy létrehozásához szükséges összes releváns információt. (Öröklődés forrása MarshalByRefObject) |
| Equals(Object) |
Elavult.
Meghatározza, hogy a megadott objektum egyenlő-e az aktuális objektummal. (Öröklődés forrása Object) |
| GetEnumerator() |
Elavult.
Lekéri azt az objektumot, amely lehetővé teszi a gyűjtemény tagjain keresztüli iterálást. (Öröklődés forrása BaseCollection) |
| GetHashCode() |
Elavult.
Ez az alapértelmezett kivonatoló függvény. (Öröklődés forrása Object) |
| GetLifetimeService() |
Elavult.
Lekéri a példány élettartamszabályzatát vezérlő aktuális élettartam-szolgáltatásobjektumot. (Öröklődés forrása MarshalByRefObject) |
| GetType() |
Elavult.
Lekéri az Type aktuális példányt. (Öröklődés forrása Object) |
| InitializeLifetimeService() |
Elavult.
Beolvas egy élettartam-szolgáltatásobjektumot a példány élettartam-szabályzatának szabályozásához. (Öröklődés forrása MarshalByRefObject) |
| MemberwiseClone() |
Elavult.
Az aktuális Objectpéldány sekély másolatát hozza létre. (Öröklődés forrása Object) |
| MemberwiseClone(Boolean) |
Elavult.
Az aktuális MarshalByRefObject objektum sekély másolatát hozza létre. (Öröklődés forrása MarshalByRefObject) |
| OnCollectionChanged(CollectionChangeEventArgs) |
Elavult.
Az eseményt emeli CollectionChanged ki. |
| Remove(DataGridTableStyle) |
Elavult.
Eltávolítja a megadott DataGridTableStyle. |
| RemoveAt(Int32) |
Elavult.
Eltávolít egy adott DataGridTableStyle indexet. |
| ToString() |
Elavult.
Az aktuális objektumot jelképező sztringet ad vissza. (Öröklődés forrása Object) |
esemény
| Name | Description |
|---|---|
| CollectionChanged |
Elavult.
Akkor fordul elő, ha a gyűjtemény megváltozott. |
Explicit interfész-implementációk
| Name | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
Elavult.
A gyűjteményt egy kompatibilis egydimenziósra Arraymásolja, a céltömb megadott indexétől kezdve. |
| ICollection.Count |
Elavult.
Lekéri a gyűjtemény elemeinek számát. |
| ICollection.IsSynchronized |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a GridTableStylesCollection hozzáférés szinkronizálva van-e (a szál biztonságos). |
| ICollection.SyncRoot |
Elavult.
Lekéri a gyűjteményhez való hozzáférés szinkronizálására használható objektumot. |
| IEnumerable.GetEnumerator() |
Elavult.
A gyűjtemény enumerátorát adja vissza. |
| IList.Add(Object) |
Elavult.
Hozzáad egy DataGridTableStyle elemet ehhez a gyűjteményhez. |
| IList.Clear() |
Elavult.
Törli a gyűjteményt. |
| IList.Contains(Object) |
Elavult.
Meghatározza, hogy egy elem szerepel-e a gyűjteményben. |
| IList.IndexOf(Object) |
Elavult.
A megadott objektum első előfordulásának nullaalapú indexét adja vissza a gyűjteményben. |
| IList.Insert(Int32, Object) |
Elavult.
Implementálja a metódust Insert(Int32, Object) . Mindig dob NotSupportedException. |
| IList.IsFixedSize |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a gyűjtemény rögzített méretű-e. |
| IList.IsReadOnly |
Elavult.
Beolvas egy értéket, amely jelzi, hogy a gyűjtemény írásvédett-e. |
| IList.Item[Int32] |
Elavult.
Lekéri vagy beállítja az elemet a megadott indexen. |
| IList.Remove(Object) |
Elavult.
Eltávolítja a megadott DataGridTableStyle. |
| IList.RemoveAt(Int32) |
Elavult.
Eltávolítja a DataGridColumnStyle megadott indexet a gyűjteményből. |
Bővítő metódusok
| Name | Description |
|---|---|
| AsParallel(IEnumerable) |
Elavult.
Lehetővé teszi a lekérdezés párhuzamosítását. |
| AsQueryable(IEnumerable) |
Elavult.
Átalakítja az egyiket IEnumerableIQueryable. |
| Cast<TResult>(IEnumerable) |
Elavult.
Egy elem elemeit IEnumerable a megadott típusra veti. |
| OfType<TResult>(IEnumerable) |
Elavult.
Egy adott típus alapján szűri IEnumerable egy adott elem elemeit. |