我想将我的checkitems列表框显示在我的收据打印预览中,但它没有读取它,当我声明checklistboxitems1时,在我的打印预览中是我检查过的唯一的最后一个。请帮我家伙太感谢你了如何获取我在列表框中的已选项目并打印到我的收据表单C#
这里是我的出纳形式
namespace Barangay_System
{
public partial class Cashier1 : Form
{
public Cashier1()
{
InitializeComponent();
}
private void checkedListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
int sum = 0;
listBox1.Items.Clear();
listBox2.Items.Clear();
label2.Text="";
foreach (string s in checkedListBox1.CheckedItems)
listBox1.Items.Add(s);
foreach (int i in checkedListBox1.CheckedIndices)
{
if (i == 0)
{
listBox2.Items.Add(300);
sum += 300;
}
if (i == 1)
{
listBox2.Items.Add(100);
sum += 100;
}
if (i == 2)
{
listBox2.Items.Add(200);
sum += 200;
}
label2.Text = sum.ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
printPreviewDialog1.Document = printDocument1;
printPreviewDialog1.ShowDialog();
}
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Bitmap bmp = Properties.Resources.Resibo;
Image newImage = bmp;
e.Graphics.DrawImage(newImage, 35, 35, newImage.Width, newImage.Height);
e.Graphics.DrawString(" Name : " + label3.Text, new Font("Arial", 18, FontStyle.Regular), Brushes.Black, new Point(30, 150));
e.Graphics.DrawString(" Requested : " + listBox1.Items.ToString(), new Font("Arial", 18, FontStyle.Regular), Brushes.Black, new Point(30, 200));
e.Graphics.DrawString(" Total : " + label2.Text, new Font("Arial", 18, FontStyle.Regular), Brushes.Black, new Point(30, 250));
}
}
}
先生您好@Abdullah Dibas太感谢你了,先生就解决 –
@HeiSciff欢迎您 –
我不删除点儿先生@Abdullah Dibas承诺 –