自动图像ID创建者

自动图像ID创建者

本文介绍了自动图像ID创建者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的会员, 我正在使用vs2008开发自动图像ID创建者。使用excel文件,图像文件夹图像。我是我的代码。我希望所有图像都放在图像容器中print.Kindly help please。 +++++++++++++++++++++++++++++++++++ Imports 系统 Imports System.ComponentModel Imports System.Diagnostics Imports System.Drawing Imports System.IO Imports System.Runtime.CompilerServices Imports System.Windows.Forms Imports Microsoft.VisualBasic.CompilerServices Public 类 Form1 私有 Sub btnOk_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 btnOk.Click Dim i as 整数 Dim openFileDialog2 As System.Windows .Forms.OpenFileDialog True True 选择 案例 i 案例 1 Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog = New System.Windows.Forms.OpenFileDialog openFileDialog1.Filter = 支持的文件| * .xls ; * .xlsx; * .csv? openFileDialog1.FilterIndex = 1 openFileDialog1.Title = 选择数据文件? openFileDialog2 = openFileDialog1 openFileDialog2.FileName = txtPath.Text openFileDialog2.ShowDialog()i = 2 GoTo label_1 案例 2 如果 Microsoft.VisualBasic.CompilerServices.Operators.CompareString(openFileDialog2.FileName, ?, False )= 0 然后 GoTo label_1 结束 如果 i = 1 结束 选择 结束 虽然 如果 不 0 然后 结束 如果 txtPath.Text = openFileDialog2.FileName txtPath.ForeColor = System .Drawing.Color.Black i = 0 结束 while label_1:_ openFileDialog2 = Nothing 结束 Sub 私有 Sub OpenFileDialog2_FileOk( ByVal sender As System。 Object , ByVal e As System.ComponentModel.CancelEventArgs)句柄 OpenFileDialog2.FileOk Dim s trm As System.IO.Stream strm = OpenFileDialog2.OpenFile() TextBox1.Text = OpenFileDialog2.FileName.ToString() 如果 不(strm Nothing )然后 ' 插入代码以读取文件数据 strm.Close() MessageBox.Show( 文件已关闭) 结束 如果 结束 Sub 私有 Sub Button1_Click( ByVal sender As 系统。对象, ByVal e As System.EventArgs)句柄 Button1.Click OpenFileDialog2.Title = 请选择一个文件 ' OpenFileDialog2.InitialDirectory =C:\ ' OpenFileDialog2.Title =打开文本文件 ' OpenFileDialog2.ShowDialog() ' OpenFileDialog2.InitialDirectory =C:\ Book11.xls ' OpenFileDialog2.Filter =Excel Files(*。xls)| * .xls OpenFileDialog2.Filter = Excel | * .xls | Word文件| * .doc |文本| * .txt ' OpenFileDialog2.ShowDialog() ' OpenFileDialog2.Filter =TextFile Files(*。text)| * .Text OpenFileDialog2.ShowDialog() ' ====================== ===== Dim MyConnection As System.Data.OleDb。 OleDbConnection Dim DtSet As System.Data.DataSet Dim MyCommand As System.Data.OleDb.OleDbDataAdapter ' 昏暗cbo As DataGridViewComboBoxCell ' MyConnection = New System.Data.OleDb.OleDbConnection(provider = Microsoft.Jet.OLEDB.4.0;数据源=+ Txt_Path.Text.ToString()+;扩展属性= Excel 8.0;) MyConnection = 新 System.Data.OleDb.OleDbConnection( provider = Microsoft.Jet.OLEDB.4.0; Data Source ='C:\ TamilGrocery \ Book1.xls';扩展属性= Excel 8.0;) MyCommand = 新系统。 Data.OleDb.OleDbDataAdapter( select * from [Sheet1 $],MyConnection) MyCommand.TableMappings.Add( 表, Net-informations.com) DtSet = 新 System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables( 0 ) MyConnection.Close() ' DataGridView1.Rows (0).Cells(0).Value = Image.FromFile(C:\TamilGrocery\WindowsApplication1\1.jpg) ' ================ For i 作为 整数 = 0 DataGridView1.Columns.Count - 1 ComboBox1.Items.Add(DataGridView1.Columns( i).Name) 下一步 ' Dim cmb As New DataGridV iewComboBoxColumn() ' cmb.HeaderText =ProID ' cmb.Name =cmb ' cmb.MaxDropDownItems = 6 ' cmb.Items.Add(True) ' cmb.Items .Add(False) ' DataGridView1.Columns.Add(cmb) 结束 Sub 私人 Sub Button2_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 Button2.Click ' Dim img As New DataGridViewImageColumn() ' Dim inImg As Image = Image.FromFile(\ C:\ TamilGrocery\WindowsApplication1 \ Image.\ 1000.jpg) ' img.Image = inImg ' DataGridView1.Columns.Add(img) ' img.HeaderText =Image ' img .Name =img ' =========== ===== ' DtSet.Tables(0).DefaultView.RowFilter =Number LIKE& txtNumber.Text& ' ' DataGridView1.DataSource = DtSet.Tables(0).DefaultView Dim textbox1 作为 新 TextBox textbox1.Name = Textbox1 textbox1.Size = 新大小( 170 , 20 ) textbox1.Location = 新点( 167 , 32 ) GroupBox1.Controls.Add(textbox1) AddHandler textbox1.TextChanged, AddressOf Text_Changed 结束 Sub 私有 Sub Text_Changed( ByVal eventSender 正如系统。对象,_ ByVal eventArgs As System.EventArgs) Dim txt As 字符串 = eventSender.Text 如果 IsNumeric(txt)然后 其他 MessageBox.Show( 请输入数值) 结束 如果 结束 Sub 私有 Sub DataGridView1_CellFormatting( ByVal sender 正如 对象, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs)句柄 DataGridView1.CellFormatting 如果 e。 ColumnIndex = 6 然后 ' 假定第三列用于图像更改基于图像需要绑定的列的值 如果 e。值 IsNot 没什么 和 不 TypeOf e.Value 位图然后 e.Value = Image.FromFile(IO.Path.Combine(Application.StartupPath) ,e.Value.ToString)) e.FormattingApplied = True 结束 如果 结束 如果 结束 Sub 私有 Sub Form1_Load( ByVal sender 作为系统。对象, ByVal e As System.EventArgs)句柄 MyBase .Load TODO:这行代码将数据加载到DatabaseDataSet.Table1表中。您可以根据需要移动或删除它。 ' Me.Table1TableAdapter.Fill( Me.DatabaseDataSet.Table1) ' Me.ReportViewer1.RefreshReport() 结束 Sub 私有 Sub ReportViewer1_Load( ByVal sender 作为系统。对象, ByVal e As System.EventArgs) 结束 Sub 私有 Sub ComboBox1_SelectedIndexChanged( ByVal 发​​送er As System。 Object , ByVal e As System.EventArgs)句柄 ComboBox1.SelectedIndexChanged 结束 Sub 私人 Sub Button3_Click( ByVal sender As 系统。对象, ByVal e As System.EventArgs)句柄 Button3.Click Dim textbox1 As 新 TextBox textbox1.Name = Textbox1 textbox1.Size = 新大小( 170 , 20 ) textbox1.Location = 新点( 167 , 32 ) GroupBox1.Controls.Add(textbox1) 结束 Sub 私有 Sub Label1_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 Label1.Click Dim label1 作为 新标签 label1.Name = label1 label1.Text = 输入名称 label1.AutoSize = True label1.Location = 新点( 80 , 33 ) GroupBox1.Controls.Add(label1) 结束 Sub 结束 类 [edit]已添加代码块 - OriginalGriff [/ edit] 解决方案 ,MyConnection) MyCommand。 TableMappings.Add( 表, Net-informations.com) DtSet = 新 System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables( 0 ) MyConnection.Close() ' DataGridView1.Rows(0) .Cells(0).Value = Image.FromFile(C:\TamilGrocery\WindowsApplication1\1.jpg) ' ================ 对于 i 作为 整数 = 0 DataGridView1.Columns.Count - 1 ComboBox1.Items.Add(DataGridView1.Columns(i)。姓名) 下一步 ' Dim cmb As New DataGridViewComboBox专栏() ' cmb.HeaderText =ProID ' cmb.Name =cmb ' cmb.MaxDropDownItems = 6 ' cmb.Items.Add(True) ' cmb.Items .Add(False) ' DataGridView1.Columns.Add(cmb) 结束 Sub 私人 Sub Button2_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 Button2.Click ' Dim img As New DataGridViewImageColumn() ' Dim inImg As Image = Image.FromFile(\ C:\ TamilGrocery \ WindowsApplication1 \ Image.\ 1000.jpg) ' img.Image = inImg ' DataGridView1.Columns.Add(img) ' img.HeaderText =图片 ' img.Name =img ' ============= === ' DtSet.Tables(0).DefaultView.RowFilter =Number LIKE& txtNumber.Text& ' ' DataGridView1.DataSource = DtSet.Tables(0).DefaultView Dim textbox1 作为 新 TextBox textbox1.Name = Textbox1 textbox1.Size = 新大小( 170 , 20 ) textbox1.Location = 新点( 167 , 32 ) GroupBox1.Controls.Add(textbox1) AddHandler textbox1.TextChanged, AddressOf Text_Changed 结束 Sub 私有 Sub Text_Changed( ByVal eventSender 正如系统。对象,_ ByVal eventArgs As System.EventArgs) Dim txt As 字符串 = eventSender.Text 如果 IsNumeric(txt)然后 其他 MessageBox.Show( 请输入数值) 结束 如果 结束 Sub 私有 Sub DataGridView1_CellFormatting( ByVal sender 正如 对象, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs)句柄 DataGridView1.CellFormatting 如果 e。 ColumnIndex = 6 然后 ' 假定第三列用于图像更改基于图像需要绑定的列的值 如果 e。值 IsNot 没什么 和 不 TypeOf e.Value 位图然后 e.Value = Image.FromFile(IO.Path.Combine(Application.StartupPath) ,e.Value.ToString)) e.FormattingApplied = True 结束 如果 结束 如果 结束 Sub 私有 Sub Form1_Load( ByVal sender 作为系统。对象, ByVal e As System.EventArgs)句柄 MyBase .Load TODO:这行代码将数据加载到DatabaseDataSet.Table1表中。您可以根据需要移动或删除它。 ' Me.Table1TableAdapter.Fill( Me.DatabaseDataSet.Table1) ' Me.ReportViewer1.RefreshReport() 结束 Sub 私有 Sub ReportViewer1_Load( ByVal sender 作为系统。对象, ByVal e As System.EventArgs) 结束 Sub 私有 Sub ComboBox1_SelectedIndexChanged( ByVal 发​​送er As System。 Object , ByVal e As System.EventArgs)句柄 ComboBox1.SelectedIndexChanged 结束 Sub 私人 Sub Button3_Click( ByVal sender As 系统。对象, ByVal e As System.EventArgs)句柄 Button3.Click Dim textbox1 As 新 TextBox textbox1.Name = Textbox1 textbox1.Size = 新大小( 170 , 20 ) textbox1.Location = 新点( 167 , 32 ) GroupBox1.Controls.Add(textbox1) 结束 Sub 私有 Sub Label1_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 Label1.Click Dim label1 作为 新标签 label1.Name = label1 label1.Text = 输入名称 label1.AutoSize = True label1.Location = New Point(80, 33) GroupBox1.Controls.Add(label1) End Sub End Class [edit]Code block added - OriginalGriff[/edit]So, you have described a task you have to do, and you have given us a code dump . Look at the code: It's full of commented out lines, magic numbers, unterminated loops, goto statements and Visual Studio default names. It’s not clear what does what (or what is supposed to do what) or what you have tried so far to complete the task you describe. So we don’t know what help you want, and I for one am not going to wade through your code dump to work out what you have actually done so far because that code is quite frankly too poor for me to want to be involved. I realise that you are a complete beginner, but this is unacceptably bad when looked at as a complete question. Edit your code, take out the rubbish, change the names to ones which reflect the use rather than the order you added them to your form, and forget that you ever met the goto statement. Then, ask us again with proper information.Dear Members,I am developing automatic image id creator using vs2008.Using excel file,folder images for image.Below is my code.I want all images to be placed in the image container and print.Kindly help please.++++++++++++++++++++Imports SystemImports System.ComponentModelImports System.DiagnosticsImports System.DrawingImports System.IOImports System.Runtime.CompilerServicesImports System.Windows.FormsImports Microsoft.VisualBasic.CompilerServicesPublic Class Form1 Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click Dim i As Integer Dim openFileDialog2 As System.Windows.Forms.OpenFileDialog While True While True Select Case i Case 1 Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog = New System.Windows.Forms.OpenFileDialog openFileDialog1.Filter = "Supported files|*.xls;*.xlsx;*.csv?" openFileDialog1.FilterIndex = 1 openFileDialog1.Title = "Select data file?" openFileDialog2 = openFileDialog1 openFileDialog2.FileName = txtPath.Text openFileDialog2.ShowDialog() i = 2 GoTo label_1 Case 2 If Microsoft.VisualBasic.CompilerServices.Operators.CompareString(openFileDialog2.FileName, "?", False) = 0 Then GoTo label_1 End If i = 1 End Select End While If Not 0 Then End If txtPath.Text = openFileDialog2.FileName txtPath.ForeColor = System.Drawing.Color.Black i = 0 End Whilelabel_1: _openFileDialog2 = Nothing End Sub Private Sub OpenFileDialog2_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog2.FileOk Dim strm As System.IO.Stream strm = OpenFileDialog2.OpenFile() TextBox1.Text = OpenFileDialog2.FileName.ToString() If Not (strm Is Nothing) Then 'insert code to read the file data strm.Close() MessageBox.Show("file closed") End If End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog2.Title = "Please Select a File" 'OpenFileDialog2.InitialDirectory = "C:\" 'OpenFileDialog2.Title = "Open a Text File" 'OpenFileDialog2.ShowDialog() 'OpenFileDialog2.InitialDirectory = "C:\Book11.xls" 'OpenFileDialog2.Filter = "Excel Files(*.xls)|*.xls" OpenFileDialog2.Filter = "Excel|*.xls|Word Files|*.doc|Text|*.txt" ' OpenFileDialog2.ShowDialog() 'OpenFileDialog2.Filter = "TextFile Files(*.text)|*.Text" OpenFileDialog2.ShowDialog() '=========================== Dim MyConnection As System.Data.OleDb.OleDbConnection Dim DtSet As System.Data.DataSet Dim MyCommand As System.Data.OleDb.OleDbDataAdapter 'Dim cbo As DataGridViewComboBoxCell 'MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Txt_Path.Text.ToString() + ";Extended Properties=Excel 8.0;") MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\TamilGrocery\Book1.xls';Extended Properties=Excel 8.0;") MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection) MyCommand.TableMappings.Add("Table", "Net-informations.com") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0) MyConnection.Close() 'DataGridView1.Rows(0).Cells(0).Value = Image.FromFile("C:\TamilGrocery\WindowsApplication1\1.jpg") '================ For i As Integer = 0 To DataGridView1.Columns.Count - 1 ComboBox1.Items.Add(DataGridView1.Columns(i).Name) Next 'Dim cmb As New DataGridViewComboBoxColumn() ' cmb.HeaderText = "ProID" 'cmb.Name = "cmb" 'cmb.MaxDropDownItems = 6 ' cmb.Items.Add("True") ' cmb.Items.Add("False") ' DataGridView1.Columns.Add(cmb) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' Dim img As New DataGridViewImageColumn() ' Dim inImg As Image = Image.FromFile("\C:\TamilGrocery\WindowsApplication1\Image\1000.jpg") ' img.Image = inImg ' DataGridView1.Columns.Add(img) ' img.HeaderText = "Image" 'img.Name = "img" '================ 'DtSet.Tables(0).DefaultView.RowFilter = "Number LIKE" & txtNumber.Text & "'" 'DataGridView1.DataSource = DtSet.Tables(0).DefaultView Dim textbox1 As New TextBox textbox1.Name = "Textbox1" textbox1.Size = New Size(170, 20) textbox1.Location = New Point(167, 32) GroupBox1.Controls.Add(textbox1) AddHandler textbox1.TextChanged, AddressOf Text_Changed End Sub Private Sub Text_Changed(ByVal eventSender As System.Object, _ ByVal eventArgs As System.EventArgs) Dim txt As String = eventSender.Text If IsNumeric(txt) Then Else MessageBox.Show("Please enter numeric value") End If End Sub Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting If e.ColumnIndex = 6 Then 'assumed third column is for image change the value based on what column your image need to bind If e.Value IsNot Nothing And Not TypeOf e.Value Is Bitmap Then e.Value = Image.FromFile(IO.Path.Combine(Application.StartupPath, e.Value.ToString)) e.FormattingApplied = True End If End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'DatabaseDataSet.Table1' table. You can move, or remove it, as needed. 'Me.Table1TableAdapter.Fill(Me.DatabaseDataSet.Table1) ' Me.ReportViewer1.RefreshReport() End Sub Private Sub ReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim textbox1 As New TextBox textbox1.Name = "Textbox1" textbox1.Size = New Size(170, 20) textbox1.Location = New Point(167, 32) GroupBox1.Controls.Add(textbox1) End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click Dim label1 As New Label label1.Name = "label1" label1.Text = "Enter Name" label1.AutoSize = True label1.Location = New Point(80, 33) GroupBox1.Controls.Add(label1) End SubEnd Class[edit]Code block added - OriginalGriff[/edit] 解决方案 ", MyConnection) MyCommand.TableMappings.Add("Table", "Net-informations.com") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0) MyConnection.Close() 'DataGridView1.Rows(0).Cells(0).Value = Image.FromFile("C:\TamilGrocery\WindowsApplication1\1.jpg") '================ For i As Integer = 0 To DataGridView1.Columns.Count - 1 ComboBox1.Items.Add(DataGridView1.Columns(i).Name) Next 'Dim cmb As New DataGridViewComboBoxColumn() ' cmb.HeaderText = "ProID" 'cmb.Name = "cmb" 'cmb.MaxDropDownItems = 6 ' cmb.Items.Add("True") ' cmb.Items.Add("False") ' DataGridView1.Columns.Add(cmb) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click ' Dim img As New DataGridViewImageColumn() ' Dim inImg As Image = Image.FromFile("\C:\TamilGrocery\WindowsApplication1\Image\1000.jpg") ' img.Image = inImg ' DataGridView1.Columns.Add(img) ' img.HeaderText = "Image" 'img.Name = "img" '================ 'DtSet.Tables(0).DefaultView.RowFilter = "Number LIKE" & txtNumber.Text & "'" 'DataGridView1.DataSource = DtSet.Tables(0).DefaultView Dim textbox1 As New TextBox textbox1.Name = "Textbox1" textbox1.Size = New Size(170, 20) textbox1.Location = New Point(167, 32) GroupBox1.Controls.Add(textbox1) AddHandler textbox1.TextChanged, AddressOf Text_Changed End Sub Private Sub Text_Changed(ByVal eventSender As System.Object, _ ByVal eventArgs As System.EventArgs) Dim txt As String = eventSender.Text If IsNumeric(txt) Then Else MessageBox.Show("Please enter numeric value") End If End Sub Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting If e.ColumnIndex = 6 Then 'assumed third column is for image change the value based on what column your image need to bind If e.Value IsNot Nothing And Not TypeOf e.Value Is Bitmap Then e.Value = Image.FromFile(IO.Path.Combine(Application.StartupPath, e.Value.ToString)) e.FormattingApplied = True End If End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'TODO: This line of code loads data into the 'DatabaseDataSet.Table1' table. You can move, or remove it, as needed. 'Me.Table1TableAdapter.Fill(Me.DatabaseDataSet.Table1) ' Me.ReportViewer1.RefreshReport() End Sub Private Sub ReportViewer1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim textbox1 As New TextBox textbox1.Name = "Textbox1" textbox1.Size = New Size(170, 20) textbox1.Location = New Point(167, 32) GroupBox1.Controls.Add(textbox1) End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click Dim label1 As New Label label1.Name = "label1" label1.Text = "Enter Name" label1.AutoSize = True label1.Location = New Point(80, 33) GroupBox1.Controls.Add(label1) End SubEnd Class[edit]Code block added - OriginalGriff[/edit]So, you have described a task you have to do, and you have given us a code dump.Look at the code: It's full of commented out lines, magic numbers, unterminated loops, goto statements and Visual Studio default names. It's not clear what does what (or what is supposed to do what) or what you have tried so far to complete the task you describe.So we don't know what help you want, and I for one am not going to wade through your code dump to work out what you have actually done so far because that code is quite frankly too poor for me to want to be involved. I realise that you are a complete beginner, but this is unacceptably bad when looked at as a complete question.Edit your code, take out the rubbish, change the names to ones which reflect the use rather than the order you added them to your form, and forget that you ever met the goto statement.Then, ask us again with proper information. 这篇关于自动图像ID创建者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-11 14:57