我正在使用Zen Barcode Rendering Framework在 C# Windows 窗体应用程序中创建条形码。我有两个文本框(一个用于条形码本身,另一个用于我希望打印在条形码标签上的相关文本)。同样,我将生成的条形码图像加载到图片框中并尝试打印该图像,但每次按下打印按钮时,结果都不合适(有时打印机打印白色的空标签,有时条形码打印不完整。有趣的是,我不得不说,为了让条形码出现在标签上,即使它看起来不完整,我必须选择非常大的纸张尺寸)。这是我的代码:
我的生成条形码按钮的点击事件的代码:
private void Button1_Click(object sender, EventArgs e)
{
string barcode = textBox1.Text;
Zen.Barcode.Code128BarcodeDraw brcd = Zen.Barcode.BarcodeDrawFactory.Code128WithChecksum;
var barcodeImage = brcd.Draw(barcode, 50);
int resultImageWidth;
if(barcodeImage.Width >= textBox2.Text.Length*8)
{
resultImageWidth = barcodeImage.Width;
}
else
{
resultImageWidth = textBox2.Text.Length*8;
}
var resultImage = new Bitmap(resultImageWidth, barcodeImage.Height + 60); // 20 is bottom padding, adjust to your text
using (var graphics = Graphics.FromImage(resultImage))
using (var font = new Font("IranYekan", 10))
using (var brush = new …Run Code Online (Sandbox Code Playgroud) 有没有办法将图片框设置为winform的接受按钮?我试图在表单属性上设置它,但它没有显示出来。感谢您的回答。
如何使用源代码(没有设计器)将Picturebox放在表单中?我试过这个:
PictureBox pb = new PictureBox();
pb.Size = new Size(10,10);
pb.Location = new Point(10,10);
pb.ImageLocation= @"C:\Users\user\Desktop\NoName\NoName\StandardPos.png";
pb.Load();
pb.Refresh();
pb.Show();
Run Code Online (Sandbox Code Playgroud)
但是有些东西我不见了.
这是否可以PictureBox在 Windows 窗体中使用三角形控件而不是矩形控件?
我想在视觉工作室的一个表格(图片框)中自由地绘制并在另一个面板/图片框上复制相同的图形(我绘制).它们也不应该是形成一条线而是一条连续线的点.请帮忙.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
Pen p_white;
bool draw = true;
private Graphics objgraphics;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
private void panel1_Paint(object sender, PaintEventArgs e)
{
Pen p_black = new Pen(new SolidBrush(Color.Black));
if (draw)
{
objgraphics = panel1.CreateGraphics();
}
}
/*private void panel1_MouseDown(object sender, MouseEventArgs e)
{
bool …Run Code Online (Sandbox Code Playgroud) 我想在图片框中显示一个pdf页面.有可能吗?如果没有,我可以在视觉工作室的窗体内显示pdf页面吗?谢谢
c# ×6
picturebox ×6
winforms ×6
.net ×1
acceptbutton ×1
barcode ×1
output ×1
panel ×1
pdf ×1
pdf-viewer ×1