CSHARPWINDOWSFORM Telegram 270
قد يقول البعض ان هذه الطريقة لاتنفع الا للادوات التي تحوي على قيم في خاصية text يعني يوجد لديهن نص كلامك صحيح ولاكن يوجد طريقة أخرى سوف نشرحها في نهاية الموضوع وهي عنطريق استخدام الخاصية AccessibleName


دالة الحدث FileClicked

DialogResult result;

private void FileClicked(object sender,EventArgs e)
{

MenuItem menu = (MenuItem)sender;
switch (menu.Text)
{
case "Save":


sfd.DefaultExt = "*.txt";
sfd.Filter = "text file (*.txt)|*.txt";


if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
sfd.FileName.Length > 0)
{

rch.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);
}

break;
case "Open":
if (rch.Modified)

result = MessageBox.Show("Do you want to continue without saving the current file?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
{
return;
}


else
{

ofd.DefaultExt = "text file |*.txt|Rich Text Files|*.rtf";
ofd.ShowDialog();

if (ofd.FileName == "")
{
return;
}
string strExt;

strExt = System.IO.Path.GetExtension(ofd.FileName);

strExt = strExt.ToUpper();

if (strExt == ".RTF")

{

rch.LoadFile(ofd.FileName, RichTextBoxStreamType.RichText);

}
else

{

System.IO.StreamReader txtReader;

txtReader = new System.IO.StreamReader(ofd.FileName);

rch.Text = txtReader.ReadToEnd();

txtReader.Close();

txtReader = null;


}
}
break;
default:
break;
}
}
شرح لبعض الخصائص الجديدة التابعة لاداة RichTextBox

الخاصية Modified

تشير إلى أن عنصر تحكم RichTextBox هل قد تم تعديله من قبل المستخدم منذ إنشاء عنصر التحكم أو تم تعيين محتوياته آخر مرة.



الدالة الأخيرة FormatClicked الخاصة بتنسيق النص

private void FormatClicked(Object Sender, EventArgs e)
{
MenuItem mniTemp = (MenuItem)Sender;

switch (mniTemp.Text)
{
case "Font":
fd.ShowColor = true;
fd.Font = this.Font;
if (fd.ShowDialog() == DialogResult.OK)
{
rch.Font = fd.Font;
rch.ForeColor = fd.Color;

this.ForeColor = fd.Color;

}
break;
}
}




ملاحظة:
عند تحميل ملف باستخدام الدالة LoadFile ، تستبدل محتويات الملف الجاري تحميله محتويات اداة التحكم RichTextBox بالكامل. سيؤدي ذلك إلى تغيير قيم خصائص النص و Rtf.

الان نشرح استخدام خاصية AccessibleName
الترجمة الحرفية لهذه الخاصية تعني اسم الوصول

هذه الخاصية تمتلكها جميع أدوات التحكم التي تظهر في الفورم

وظيفتها تشبه الى حد ما الخاصية text ولاكن الاختلاف الوحيد هو ان خاصية اسم الوصول لاتظهر على الأداة وتستخدم كمعرف للوصول الى الأداة



tgoop.com/CsharpWindowsForm/270
Create:
Last Update:

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


دالة الحدث FileClicked

DialogResult result;

private void FileClicked(object sender,EventArgs e)
{

MenuItem menu = (MenuItem)sender;
switch (menu.Text)
{
case "Save":


sfd.DefaultExt = "*.txt";
sfd.Filter = "text file (*.txt)|*.txt";


if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
sfd.FileName.Length > 0)
{

rch.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);
}

break;
case "Open":
if (rch.Modified)

result = MessageBox.Show("Do you want to continue without saving the current file?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.No)
{
return;
}


else
{

ofd.DefaultExt = "text file |*.txt|Rich Text Files|*.rtf";
ofd.ShowDialog();

if (ofd.FileName == "")
{
return;
}
string strExt;

strExt = System.IO.Path.GetExtension(ofd.FileName);

strExt = strExt.ToUpper();

if (strExt == ".RTF")

{

rch.LoadFile(ofd.FileName, RichTextBoxStreamType.RichText);

}
else

{

System.IO.StreamReader txtReader;

txtReader = new System.IO.StreamReader(ofd.FileName);

rch.Text = txtReader.ReadToEnd();

txtReader.Close();

txtReader = null;


}
}
break;
default:
break;
}
}
شرح لبعض الخصائص الجديدة التابعة لاداة RichTextBox

الخاصية Modified

تشير إلى أن عنصر تحكم RichTextBox هل قد تم تعديله من قبل المستخدم منذ إنشاء عنصر التحكم أو تم تعيين محتوياته آخر مرة.



الدالة الأخيرة FormatClicked الخاصة بتنسيق النص

private void FormatClicked(Object Sender, EventArgs e)
{
MenuItem mniTemp = (MenuItem)Sender;

switch (mniTemp.Text)
{
case "Font":
fd.ShowColor = true;
fd.Font = this.Font;
if (fd.ShowDialog() == DialogResult.OK)
{
rch.Font = fd.Font;
rch.ForeColor = fd.Color;

this.ForeColor = fd.Color;

}
break;
}
}




ملاحظة:
عند تحميل ملف باستخدام الدالة LoadFile ، تستبدل محتويات الملف الجاري تحميله محتويات اداة التحكم RichTextBox بالكامل. سيؤدي ذلك إلى تغيير قيم خصائص النص و Rtf.

الان نشرح استخدام خاصية AccessibleName
الترجمة الحرفية لهذه الخاصية تعني اسم الوصول

هذه الخاصية تمتلكها جميع أدوات التحكم التي تظهر في الفورم

وظيفتها تشبه الى حد ما الخاصية text ولاكن الاختلاف الوحيد هو ان خاصية اسم الوصول لاتظهر على الأداة وتستخدم كمعرف للوصول الى الأداة

BY برمجة تطبيقات الويندوز C# Programming


Share with your friend now:
tgoop.com/CsharpWindowsForm/270

View MORE
Open in Telegram


Telegram News

Date: |

Private channels are only accessible to subscribers and don’t appear in public searches. To join a private channel, you need to receive a link from the owner (administrator). A private channel is an excellent solution for companies and teams. You can also use this type of channel to write down personal notes, reflections, etc. By the way, you can make your private channel public at any moment. Joined by Telegram's representative in Brazil, Alan Campos, Perekopsky noted the platform was unable to cater to some of the TSE requests due to the company's operational setup. But Perekopsky added that these requests could be studied for future implementation. Polls Ng, who had pleaded not guilty to all charges, had been detained for more than 20 months. His channel was said to have contained around 120 messages and photos that incited others to vandalise pro-government shops and commit criminal damage targeting police stations. The initiatives announced by Perekopsky include monitoring the content in groups. According to the executive, posts identified as lacking context or as containing false information will be flagged as a potential source of disinformation. The content is then forwarded to Telegram's fact-checking channels for analysis and subsequent publication of verified information.
from us


Telegram برمجة تطبيقات الويندوز C# Programming
FROM American