الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

ساعدوني في هذا الكود لجعل كتابة لا تتعدى الاطار

بدأه doudi في 17 أبريل 2011 · 3 رد · 314 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم ورحمة الله وبركاته

اخواني ارجو منكم المساعدة على هاذا الكود الذي هو عبارة عن فورم يقوم بعرض الصفحات بتحديد معين مع عرض اطار بداخلهم

الان اريد عرض كتابة بداخل هذه الصفحات بشرط ان لا تتعدى الكتابة هذا الاطار

وجازاكم الله خير الجزاء

اذا كان سؤالي فيه بعض الغموض قولو لي نقطة الغموض باذن الله اوضحها لكم

فقكط ارجو الرد في اقرب وقت

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace WindowsFormsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void textBox1_TextChanged(object sender, EventArgs e)

{

}

private void textBox1_Validating(object sender, CancelEventArgs e)

{

try

{

int x = Int32.Parse(textBox1.Text);

errorProvider1.SetError(textBox1, "");

}

catch (Exception )

{

errorProvider1.SetError(textBox1, "Not an integer value.");

}

}

private void textBox2_Validating(object sender, CancelEventArgs e)

{

try

{

int x = Int32.Parse(textBox2.Text);

errorProvider1.SetError(textBox2, "");

}

catch (Exception )

{

errorProvider1.SetError(textBox2, "Not an integer value.");

}

}

private void button1_Click(object sender, EventArgs e)

{

printPreviewDialog1.ShowDialog();

}

private void Form1_Load(object sender, EventArgs e)

{

}

Font f = new Font("times new romain ", 14, FontStyle.Bold);

private void Form1_Paint(object sender, PaintEventArgs e)

{

//e.Graphics.DrawString (" teste",f,Brushes.Black,10,10);

//e.Graphics.DrawRectangle(Pens.Red, 10, 10, 100, 30);

RectangleF rf = new RectangleF(10, 20, 200, 40);

StringFormat sf = new StringFormat();

sf.Alignment = StringAlignment.Center;

string s = "je comprie pas rien";

float h = f.GetHeight(e.Graphics);

float w = e.Graphics.MeasureString(s, f).Width;

e.Graphics.DrawRectangle(Pens.Blue, rf.X, rf.Y, rf.Width, rf.Height);

e.Graphics.DrawString(s, f, Brushes.Black, rf, sf);

e.Graphics.DrawString(s, f, Brushes.Black, 5, 10);

}

int X = 0;

Pen pen = new Pen(Color.Red,10f);

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)

{

e.Graphics.DrawString(X.ToString(), f, Brushes.Blue, 10, 10);

e.Graphics.DrawRectangle(pen, e.PageBounds.X + 1, e.PageBounds.Y + 1, e.PageBounds.Width-2,e.PageBounds.Height-2);

e.Graphics.DrawRectangle(pen, e.MarginBounds);

StringFormat sf = new StringFormat();

sf.Alignment = StringAlignment.Center;

RectangleF Footbounds = new RectangleF(e.MarginBounds.Left, e.MarginBounds.Bottom, e.MarginBounds.Width, f.GetHeight(e.Graphics));

e.Graphics.DrawString(X.ToString(), f, Brushes.Blue, Footbounds, sf);

if (X < 10)

{

e.HasMorePages = true; X += 1;

}else

{ e.HasMorePages = false; }

}}

}

#2

السلام عليكم ورحمه الله وبركاته

جرب الكود التالي


{
RectangleF rf = new RectangleF(10, 20, 200, 40);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
string s = "je comprie pas rien.........................";
float h = f.GetHeight(e.Graphics);
float w = e.Graphics.MeasureString(s, f).Width;
e.Graphics.DrawRectangle(Pens.Blue, rf.X, rf.Y, rf.Width, rf.Height);
e.Graphics.DrawString(s,f,Brushes.Blue,rf,sf);
}
  private void Form1_Paint(object sender, PaintEventArgs e)

.:: Wish to become better and better ::.

#3

شكرا جزيلا على الرد

لكن يبدو اني لم افصل بشكل واضح

بالنسبة للجزء الذي يحتوي على errere provider غير مهم

المهم في انو الكتابة كما طلبت تكون داخل الاطار امحدد والذي هو اصلا موجود قي هذا الكود

ايضا يجب ان تكون كل الاسطر لها طول متساوي ليكو ن شكلها في النهاية متناسق

مثل التعليمة الموجودة في الوورد رمز صغير بجانب التجانب

ايضا هنا توجدPrintPreviewDialogue اريد ان تكون الكتابة فيه وليس في الفورم

شكرا جزيلا

#4

السلام عليكم ورحمه الله وبركاته

بالنسبه للأول ابعد المحاذاه .. اما الثاني فقم بوضع كود الطباعه في حدث ال PrintPage للمستند

.:: Wish to become better and better ::.

مواضيع مشابهة

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…