DataColumn.ReadOnly Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur nilai yang menunjukkan apakah kolom memungkinkan perubahan segera setelah baris ditambahkan ke tabel.
public:
property bool ReadOnly { bool get(); void set(bool value); };
public bool ReadOnly { get; set; }
[System.Data.DataSysDescription("DataColumnReadOnlyDescr")]
public bool ReadOnly { get; set; }
member this.ReadOnly : bool with get, set
[<System.Data.DataSysDescription("DataColumnReadOnlyDescr")>]
member this.ReadOnly : bool with get, set
Public Property ReadOnly As Boolean
Nilai Properti
true
jika kolom hanya dibaca; jika tidak, false
. Default adalah false
.
- Atribut
Pengecualian
Properti diatur ke false
pada kolom komputasi.
Contoh
Contoh berikut membuat DataColumn dan mengatur propertinya ReadOnlytrue
.
private void AddColumn(DataTable table)
{
// Add a DataColumn to the collection and set its properties.
// The constructor sets the ColumnName of the column.
DataColumn column = table.Columns.Add("Total");
column.DataType = System.Type.GetType("System.Decimal");
column.ReadOnly = true;
column.Expression = "UnitPrice * Quantity";
column.Unique = false;
}
Private Sub AddColumn(ByVal table As DataTable)
' Add a DataColumn to the collection and set its properties.
' The constructor sets the ColumnName of the column.
Dim column As DataColumn = table.Columns.Add("Total")
column.DataType = System.Type.GetType("System.Decimal")
column.ReadOnly = True
column.Expression = "UnitPrice * Quantity"
column.Unique = False
End Sub
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk