BarCode for WinForms快速入门 > 步骤二:将代码添加到项目 |
在上一步中您已经设置了窗体并向工程添加了一个C1BarCode,您将继续向工程添加代码。
完成以下步骤:
Visual Basic
Visual Basic |
拷贝代码
|
---|---|
C1BarCode1.Text = TextBox1.Text |
C#
C# |
拷贝代码
|
---|---|
c1BarCode1.Text = TextBox1.Text; |
注意:您必须向Form代码的开始添加 Imports C1.Win.C1BarCode(Visual Basic 工程)或者using C1.Win.C1BarCode(C#工程)以便使得以下代码正常工作。 |
Visual Basic
Visual Basic |
拷贝代码
|
---|---|
Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.Codabar End Sub Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.Code128 End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.Code39 End Sub Private Sub RadioButton4_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton4.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.Code93 End Sub Private Sub RadioButton5_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton5.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.CodeI2of5 End Sub Private Sub RadioButton6_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton6.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.Ean13 End Sub Private Sub RadioButton7_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton7.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.Ean8 End Sub Private Sub RadioButton8_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton8.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.PostNet End Sub Private Sub RadioButton9_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton9.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.UpcA End Sub Private Sub RadioButton10_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton10.CheckedChanged C1BarCode1.CodeType = CodeTypeEnum.UpcE End Sub |
C#
C# |
拷贝代码
|
---|---|
private void radioButton1_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.Codabar; } private void radioButton2_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.Code128; } private void radioButton3_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.Code39; } private void radioButton4_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.Code93; } private void radioButton5_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.CodeI2of5; } private void radioButton6_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.Ean13; } private void radioButton7_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.Ean8; } private void radioButton8_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.PostNet; } private void radioButton9_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.UpcA; } private void radioButton10_CheckedChanged(object sender, System.EventArgs e) { c1BarCode1.CodeType = CodeTypeEnum.UpcE; } |
你刚刚完成ComponentOne BarCode for WinForms快速入门的第二步。继续下一步,运行并查看工程运行结果。