Software එකකදි user (ඒක පාවිච්චි කරන කෙනා) හට යමක් දැනුම්දෙන්න පහසු ක්‍රමයක් තමා Message Box.
මෙහි පද ගැලපුම පහත පරිදියි.(Syntax)

- Proudly Presents by Sadeepa -

MessageBox.Show(“prompt”,”Title”,MessageBoxButtons.Buttons,MessageBoxIcon.Icontype);

මෙහි Promt යන කොටසට ලබා දෙන්නෙ message box එකේ අන්තර්ගත පණිවිඩය.

Tilte කොටසට ලබා දෙන්නෙ message box එකේ Title එක.

Buttons කියන තෙනට දෙන්නෙ Message box එකට දාන Buttons.
Ex:- Ok / OkCancel / YesNo / AbortRetryCancel / YesNoCancel

Icontype එකට දෙන්නෙ message box එකේ පෙන්විය යුතු Icon එක.
Ex:- Error / Stop / Information / Question / Exclamation

සරල උදාහරණයක් බලමු. 

MessageBox.Show("Hello I'm Sadeepa","This is the title",MessageBoxButtons.OK,MessageBoxIcon.Information);

ඔය button එකේ output එක වෙන්නෙ,

තව එකක්, 
MessageBox.Show("C# Lesson 3 - Message box භාවිතා කිරීම", "http://sadeepa01.blogspot.com/", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MessageBox.Show("C# Lesson 3 - Message box භාවිතා කිරීම", "http://sadeepa01.blogspot.com/", MessageBoxButtons.YesNo, MessageBoxIcon.Stop);

හරි දැන් බලමු මෙයට ලබා දෙන Button එකක් press කළ විට තවත් code එකක් ක්‍රියාත්මක කරන ආකාරය. ඒ සඳහා මාගේ පෙර ලිපියේ විස්තර කළ If Conditions භාවිතා කරනවා.

DialogResult dr;
            dr = MessageBox.Show("Close the app?", "Warning!!", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr.ToString() == "Yes")
            {
                Application.Exit();
            }

මෙහි Yes ලෙස ලබා දුන්නොත් වැඩසටහනෙන් ඉවත් වීමට code එක ලබා දී ඇත. Death Clock එකේදිත් යාලුවන්ට දකින්න ලබුණු එක් Message box එකක Coding එක පහත පරිදියි,

if (textBox1.Text == "" || txtBdate.Text == "" || txtBmonth.Text == "" || txtByear.Text == "")
            {
                MessageBox.Show("Error Fill all Fields correct");
            }
මෙමගින් සිදුවන්නේ එක් Text box එකක් හෝ හිස්ව තබන්නේ නම් Message box එකකින් එය දැනුම් දීමයි.
Software හදනවානම් මේවත් දැනගෙන ඉන්න එක වටිනවානේ.

* _______________________________________________________ *
වෙබ් අඩවියේ සාමාජිකයෙකු වීමට වම් පස පහලම Join This Site මත Click කරන්න.ඔබට එවිට එසැනින් අලුත් ලිපි ලබා ගත හැක.

තවත් මේවගේ වටින කියන ලිපියකින් හමුවෙමු.
ඔබේ වටිනා අදහස් පහතින් දාන්නත් පුලුවන්
Amazin
Powered by Blogger.