ReadOnly
How do I use Read Only
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: LoadbalancingPeer.cs
Copy
29 private readonly Dictionary31 public LoadbalancingPeer(IPhotonPeerListener listener, ConnectionProtocol protocolType) : base(listener, protocolType)
32 {
33 }
File name: NetworkingPeer.cs
Copy
144 private readonly Dictionary145 private readonly Dictionary
152 internal protected ServerConnection server { get; private set; }
File name: NetworkingPeer.cs
Copy
163 private static readonly Dictionary
File name: ChatClient.cs
Copy
77 private static readonly Dictionary
File name: ImportUtils.cs
Copy
92 public static void ReadyToWrite(string path)
93 {
94 // Creates directories in path if they don't exist
95 FileInfo info = new FileInfo(path);
96 info.Directory.Create();
97
98 // Make sure file is not readonly
99 if ((info.Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
100 {
101 throw new UnityException(String.Format("{0} is read-only", path));
102 }
103 }
File name: frmQLThe.cs
Copy
72 private void btnclear_Click(object sender, EventArgs e)
73 {
74 foreach (Control ctr in groupBox1.Controls)
75 {
76 if (ctr is TextBox || ctr is ComboBox || ctr is MaskedTextBox)
77 {
78 ctr.Text = "";
79 }
80 }
81 cbxMaDG.Focus();
82 txtMaThe.ReadOnly = false;
83 mklNgayCap.Text = date.ToString("dd/MM/yyyy");
84 mktHan.Text = date.AddYears(1).ToString("dd/MM/yyyy");
85 }
File name: frmQLThe.cs
Copy
87 private void btninsert_Click(object sender, EventArgs e)
88 {
89 btninsert.Image = Resources.Cancel;
90 BtnThem(false);
91 btnSave.Enabled = true;
92 txtMaThe.ReadOnly = false;
93 cbxMaDG.Focus();
94 }
File name: frmQLThe.cs
Copy
96 private void btnupdate_Click(object sender, EventArgs e)
97 {
98 btnupdate.Image = Resources.Cancel;
99 BtnSua(false);
100 btnSave.Enabled = true;
101 txtMaThe.ReadOnly = true;
102 mklNgayCap.ReadOnly = false;
103 mktHan.ReadOnly = false;
104 cbxMaDG.Focus();
105
106 }
File name: frmQLThe.cs
Copy
127 private void buttonX2_Click(object sender, EventArgs e)
128 {
129 btnSave.Enabled = false;
130 BtnThem(true);
131 BtnSua(true);
132 btninsert.Image = Resources.add1_;
133 btnupdate.Image = Resources.edit;
134 txtMaThe.ReadOnly = true;
135 cbxMaDG.Focus();
136 }
File name: frmQLThe.cs
Copy
138 private void btnSave_Click(object sender, EventArgs e)
139 {
140 if (btnupdate.Enabled==false)
141 {
142 try
143 {
144 tbThe test = (db.tbThes.Where(t => t.MaThe == txtMaThe.Text).SingleOrDefault
145 if (test!=null)
146 {
147 MessageBox.Show("Mã Thẻ Đã Tòn Tại","Thông Báo",MessageBoxButtons.OK,MessageBoxIcon.Warning);
148 return;
149 }
150 else
151 {
152 if (db.CRUDThe('t', txtMaThe.Text, cbxMaDG.Text, mklNgayCap.Text, mktHan.Text) == 1)
153 {
154 db.SubmitChanges();
155 MessageBox.Show("Thêm Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
156 }
157 else
158 MessageBox.Show("Thêm Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
159 }
160
161 }
162 catch (Exception ex)
163 {
164 MessageBox.Show(ex.Message, "Quản Lý Thư Viện");
165 }
166 finally
167 {
168 tbTHE.LoadGridView(dataGridViewX1);
169 btninsert.Image = Resources.add1_;
170 BtnThem(true);
171 txtMaThe.ReadOnly = true;
172 btnSave.Enabled = false;
173 }
174 }
175 if (btninsert.Enabled==false)
176 {
177 try
178 {
179 if (MessageBox.Show("Bạn Có Muốn Sửa Không","Thông Báo",MessageBoxButtons.YesNo,MessageBoxIcon.Question)==DialogResult.Yes)
180 {
181 tbThe test = (db.tbThes.Where(t => t.MaThe == txtMaThe.Text).SingleOrDefault
182 if (test != null)
183 {
184 if (db.CRUDThe('t',txtMaThe.Text,cbxMaDG.Text,mklNgayCap.Text,mktHan.Text)==1)
185 {
186 db.SubmitChanges();
187 MessageBox.Show("Sửa Thành Công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
188 }
189 else
190 {
191 MessageBox.Show("Sửa Thất Bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
192 }
193 }
194 else
195 MessageBox.Show("Mã Thẻ Không Tòn Tại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
196
197 }
198
199 }
200 catch (Exception ex)
201 {
202 MessageBox.Show(ex.Message, "Quản Lý Thư Viện");
203 }
204 finally
205 {
206
207 //var query = (from tbTHE in db.tbThes
208 // join tbDOCGIA in db.tbDGs
209 // on tbTHE.MaDG equals tbDOCGIA.MaDG
210 // select new
211 // {
212 // tbDOCGIA.MaDG,
213 // tbDOCGIA.TenDG,
214 // tbDOCGIA.ChucVu,
215 // tbTHE.MaThe,
216 // tbTHE.NgayCap,
217 // tbTHE.Han
218 // });
219 //dataGridViewX1.DataSource = query;
220 tbThe tbthenew = new tbThe();
221 tbthenew.LoadGridView(dataGridViewX1);
222 BtnThem(true);
223 txtMaThe.ReadOnly = true;
224 mklNgayCap.ReadOnly = true;
225 mktHan.ReadOnly = false;
226 btnupdate.Image = Resources.edit;
227 btnSave.Enabled = false;
228 }
229 }
230 }
ReadOnly 207 lượt xem
Gõ tìm kiếm nhanh...