private void loadData(List <string> list_uuids) { DataTable dtData = ctrl.getqrcode(list_uuids); for (int i = 0; i < dtData.Rows.Count; i++) { Bitmap bm = util.GenByZXingNet(dtData.Rows[i]["num"].ToString()); picModel pm = new picModel(); pm.printBmp = bm; pm.batch = "批次号:" + dtData.Rows[i]["num"].ToString(); pm.num = "物料编码:" + dtData.Rows[i]["mnum"].ToString(); pm.name = "物料名称:" + dtData.Rows[i]["name"].ToString(); if (dtData.Rows[i]["spe"] != DBNull.Value) { pm.spe = "规格型号:" + dtData.Rows[i]["spe"].ToString(); } if (dtData.Rows[i]["attribute"] != DBNull.Value) { pm.attribute = "物料属性:" + dtData.Rows[i]["attribute"].ToString(); } pm.supplier = "供应商:" + dtData.Rows[i]["supplier"].ToString(); _printBmps.Add(pm); imageList1.Images.Add(bm); ListViewItem li = new ListViewItem(); li.Text = dtData.Rows[i]["num"].ToString(); li.ImageIndex = i; //对应指定即可 listView1.Items.Add(li); } imageList1.ImageSize = new Size(112, 112); this.listView1.LargeImageList = imageList1; }
private void toolStripButton2_Click(object sender, EventArgs e) { if (this.dataGridView1.SelectedRows.Count == 0) { MessageBox.Show("请选择行!"); return; } else { _printBmps = new List <picModel>(); for (int i = 0; i < this.dataGridView1.SelectedRows.Count; i++) { picModel pm = new picModel(); pm.printBmp = util.GenByZXingNet(this.dataGridView1.SelectedRows[i].Cells["num"].Value.ToString()); pm.batch = "批次号:" + this.dataGridView1.SelectedRows[i].Cells["num"].Value.ToString(); pm.num = "物料编码:" + this.dataGridView1.SelectedRows[i].Cells["mnum"].Value.ToString(); pm.name = "物料名称:" + this.dataGridView1.SelectedRows[i].Cells["name"].Value.ToString(); if (this.dataGridView1.SelectedRows[i].Cells["spe"].Value != DBNull.Value) { pm.spe = "规格型号:" + this.dataGridView1.SelectedRows[i].Cells["spe"].Value.ToString(); } pm.attribute = "物料属性:" + this.dataGridView1.SelectedRows[i].Cells["attribute"].Value.ToString(); pm.supplier = "供应商:" + this.dataGridView1.SelectedRows[i].Cells["supplier"].Value.ToString(); _printBmps.Add(pm); //(Bitmap)this.dataGridView1.SelectedRows[i].Cells["image"].Value } PrintPriview(); } }
private string getmax(picModel pm) { string max = ""; foreach (System.Reflection.PropertyInfo p in pm.GetType().GetProperties()) { if (p.Name != "printBmp") { if (p.GetValue(pm, null).ToString().Length > max.Length) { max = p.GetValue(pm, null).ToString(); } } } return(max); }