I have a button click event:
private void button1_Click(object sender, EventArgs e)
{
try
{
conn.Open();
string query = "INSERT INTO bank_check_kassa OUTPUT INSERTED.formatted_id default values";
SqlCommand command = new SqlCommand(query, conn);
string insertedID = (string)command.ExecuteScalar();
label1.Padding = new Padding(-50, 0, 0, 0);
label1.Text = "Novbedeki siraniz " + insertedID.ToString();
// Printer ayarları
using (PrintDocument pd = new PrintDocument())
{
// Yazdırma işlemi
pd.PrintPage += (s, args) => ProvideContent1(s, args, insertedID);
pd.Print();
}
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
finally
{
conn.Close();
}
}
private void ProvideContent1(object sender, PrintPageEventArgs e, string insertedID)
{
// Создание шрифта для текста
Font font = new Font("Arial", 12, FontStyle.Regular);
// Создание кисти для текста
SolidBrush brush = new SolidBrush(Color.Black);
// Определение координаты для вывода текста
float x = 100;
float y = 100;
// Вывод текста на документ
e.Graphics.DrawString("Novbedeki siraniz: " + insertedID, font, brush, x, y);
}
This works, in that information on the label will appear. However, I want to print the information immediately, and for some reason it doesn't go to print. Instead, I see the print dialog. What I want is to mark the printer by default so that the test can print without waiting (skip the dialog).
How can I do this?