//读取
private void showMess() { this.dataGridViewX2.Rows.Clear(); //将车辆信息一行行添加到datagreatview 里面 StreamReader sr = File.OpenText("C:\Users\Administrator\Desktop\CarMessages.txt"); string line; int i = 0; List<string> list = new List<string>(); while ((line = sr.ReadLine()) != null) { list.Add(line); i++; } dataGridViewX2.Rows.Add(i); int qq = list.Count; for (int a = 0; a < qq; a++) { dataGridViewX2.Rows[a].Cells[0].Value = list[a].ToString(); } //列宽自适应 dataGridViewX2.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; dataGridViewX2.ReadOnly = true; }
写入Text
try { MultiFormatWriter mutiWriter = new com.google.zxing.MultiFormatWriter(); ByteMatrix bm = mutiWriter.encode( table.Rows[0]["CarID"].ToString() , com.google.zxing.BarcodeFormat.QR_CODE, 363, 150); Bitmap img = bm.ToBitmap(); string filename = "C:\Users\Administrator\Desktop\Car_Messages\" + table.Rows[0]["MenName"].ToString() + table.Rows[0]["CarID"].ToString() + ".jpg"; img.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg); } catch (Exception ee) { MessageBox.Show(ee.Message); } }