The document discusses various form controls and techniques in Windows Forms applications, including:
- Message boxes for displaying information to users
- Validating textbox input to only allow certain characters
- Minimizing, maximizing and restoring a form's window state
- Clearing text from textboxes and comboboxes in a form
- Radio buttons, check boxes, and list boxes
- Creating timers and tabbed dialog boxes
- Adding menu items, shortcuts, and toolbars
- Creating multiple document interface (MDI) forms with a parent window containing child windows.
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)Jannat Ruma
This is provided as a course material in the Workshop named "Workshop on C# Programming: Learn to Build" organized by East West University Computer Programming Club (EWUCoPC) & supported by Young Engineers Society (YES).
The Vara Framework for Adobe Flex makes it easier for developers to build consistent, user-friendly apps. It is primarily to help keep CRUD operations organized along with user interaction such as prompting to save changes and making remote calls.
This presentation was given at the OC Flex group in Irvine, CA. It was given along with the first public release of the source code and SWC library which can be found on SourceForge at http://sourceforge.net/projects/vara/.
Windows Form - Lec12 (Workshop on C# Programming: Learn to Build)Jannat Ruma
This is provided as a course material in the Workshop named "Workshop on C# Programming: Learn to Build" organized by East West University Computer Programming Club (EWUCoPC) & supported by Young Engineers Society (YES).
The Vara Framework for Adobe Flex makes it easier for developers to build consistent, user-friendly apps. It is primarily to help keep CRUD operations organized along with user interaction such as prompting to save changes and making remote calls.
This presentation was given at the OC Flex group in Irvine, CA. It was given along with the first public release of the source code and SWC library which can be found on SourceForge at http://sourceforge.net/projects/vara/.
asp.net using c# notes sem 5 ( we-it tutorials ).
Review of .NET frameworks, Introduction to C#, Variables and expressions, flow controls, functions, debugging and error handling, OOPs with C#, Defining classes and class members.
Assembly, Components of Assembly, Private and Shared Assembly, Garbage Collector, JIT compiler. Namespaces Collections, Delegates and Events. Introduction to ASP.NET 4: Microsoft.NET framework, ASP.NET lifecycle. CSS: Need of CSS, Introduction to CSS, Working with CSS with visual developer.
ASP.NET server controls: Introduction, How to work with button controls, Textboxes, Labels, checkboxes and radio buttons, list controls and other web server controls, web.config and global.asax files. Programming ASP.NET web pages: Introduction, data types and variables, statements, organizing code, object oriented basics.
Validation Control: Introduction, basic validation controls, validation techniques, using advanced validation controls. State Management: Using view state, using session state, using application state, using cookies and URL encoding. Master Pages: Creating master pages, content pages, nesting master pages, accessing master page controls from a content page. Navigation: Introduction to use the site navigation, using site navigation controls.
Databases: Introduction, using SQL data sources, GridView Control, DetailsView and FormView Controls, ListView and DataPager controls, Using object datasources. ASP.NET Security: Authentication, Authorization, Impersonation, ASP.NET provider model
LINQ: Operators, implementations, LINQ to objects,XML,ADO.NET, Query Syntax. ASP.NET Ajax: Introducing AJAX, Working of AJAX, Using ASP.NET AJAX
server controls. JQuery: Introduction to JQuery, JQuery UI Library, Working of JQuery
We've all seen the big "macro" features in .NET, this presentation is to give praise to the "Little Wonders" of .NET -- those little items in the framework that make life as a developer that much easier!
Windows Forms , Form Class , Common Operations on Forms , Creating a Message Box ,Handling Events ,Mouse Events,Keyboard Events , Common Controls in Windows Forms,Label , TextBox , Button , Combo Box , List Box , Check Box , Radio Button , Group Box , Picture Box , Timer , Open File Dialog , Save File Dialog , Font Dialog, Color Dialog ,Print Dialog ,Tree View ,Menu,PROGRAMMING,C#,C# CONCEPTS,SIMPLE CONCEPTS IN C#.
asp.net using c# notes sem 5 ( we-it tutorials ).
Review of .NET frameworks, Introduction to C#, Variables and expressions, flow controls, functions, debugging and error handling, OOPs with C#, Defining classes and class members.
Assembly, Components of Assembly, Private and Shared Assembly, Garbage Collector, JIT compiler. Namespaces Collections, Delegates and Events. Introduction to ASP.NET 4: Microsoft.NET framework, ASP.NET lifecycle. CSS: Need of CSS, Introduction to CSS, Working with CSS with visual developer.
ASP.NET server controls: Introduction, How to work with button controls, Textboxes, Labels, checkboxes and radio buttons, list controls and other web server controls, web.config and global.asax files. Programming ASP.NET web pages: Introduction, data types and variables, statements, organizing code, object oriented basics.
Validation Control: Introduction, basic validation controls, validation techniques, using advanced validation controls. State Management: Using view state, using session state, using application state, using cookies and URL encoding. Master Pages: Creating master pages, content pages, nesting master pages, accessing master page controls from a content page. Navigation: Introduction to use the site navigation, using site navigation controls.
Databases: Introduction, using SQL data sources, GridView Control, DetailsView and FormView Controls, ListView and DataPager controls, Using object datasources. ASP.NET Security: Authentication, Authorization, Impersonation, ASP.NET provider model
LINQ: Operators, implementations, LINQ to objects,XML,ADO.NET, Query Syntax. ASP.NET Ajax: Introducing AJAX, Working of AJAX, Using ASP.NET AJAX
server controls. JQuery: Introduction to JQuery, JQuery UI Library, Working of JQuery
We've all seen the big "macro" features in .NET, this presentation is to give praise to the "Little Wonders" of .NET -- those little items in the framework that make life as a developer that much easier!
Windows Forms , Form Class , Common Operations on Forms , Creating a Message Box ,Handling Events ,Mouse Events,Keyboard Events , Common Controls in Windows Forms,Label , TextBox , Button , Combo Box , List Box , Check Box , Radio Button , Group Box , Picture Box , Timer , Open File Dialog , Save File Dialog , Font Dialog, Color Dialog ,Print Dialog ,Tree View ,Menu,PROGRAMMING,C#,C# CONCEPTS,SIMPLE CONCEPTS IN C#.
You have been engaged to develop a special calculator program. T.docxbriancrawford30935
You have been engaged to develop a special calculator program. The requirements for this program are very specific, and are as follows:
Create a Windows Forms application in Visual Studio using C#. The interface should look similar to the following:
Create the following controls, as shown above:
Labels for “Enter Information,” “Name,” “Input 1,” and “Input 2”
3 textboxes, as shown in the picture above
Buttons for addition, subtraction, multiplication, and division
Buttons for calculating sine, cosine, and tangent (based on the first input textbox only)
A button that calculates modulus
A button that clears the textboxes
Write a method for each of these calculations that will accept the incoming numbers from the two input fields and return the calculated value.
This value should be displayed in a MessageBox window, which should also display the user’s name from the first textbox.
Please submit your zipped Visual Studio project.
.
• Validating Textbox input using ‘Validating’ event
• Using KeyPress event to identify input character in Textbox
• Using various built in methods of ReachTextbox
• Using various dialogboxes
• Using following controls:
o ReachTextBox
o Menustrip
o Toolstrip
o Statusbar
o DialogBoxes: OpenFileDialog,SaveFileDialog, FontDialog, ColorDialog
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
2. Message Boxes
• A message box is a special dialog box used to display a piece of information to user.
– MessageBox class
– EX:
MessageBox.Show("Hello, how are you?","My SMS");
MessageBox.Show("Welcome to the Wonderful World of Visual C#","Visual C#
Tutorials", MessageBoxButtons.OKCancel);
MessageBox.Show("Your order appears to be correct" +
"nAre you ready to provide your credit card information?",
"Customer Order Processing",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Information);
3. EX:
MessageBox.Show("Your order appears to be correct" +
"nAre you ready to provide your credit card information?",
"Customer Order Processing",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1);
NOTE:Button1 , Button2 , Button3
12. 1. Adding Menu Items
2. Creating Checked Menu Items
3. Assigning Shortcut Keys
4. Using the Toolbar Control
13. Creating MDI Forms
All the projects you've created so far have been single-document interface (SDI) projects. In SDI
programs, every form in the application is a peer of all other forms; no intrinsic hierarchy exists
between forms. C# also lets you create multiple-document interface (MDI) programs. A MDI
program contains one parent window (also called a container) and one or more child windows.
A classic example of a MDI program is Microsoft Word 95 (200 behaves slightly different,
depending on how it's set up).
if (MessageBox.Show("Would you like to do X?", "MessageBoxsample", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
this.Close();
}
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 WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.Text = DateTime.Now.ToString();
this.rSum.Checked = true;
}
private void rSum_CheckedChanged(object sender, EventArgs e)
{
this.lbOp.Text = "+";
this.btOP.Text = "+";
}
private void rMinus_CheckedChanged(object sender, EventArgs e)
{
this.lbOp.Text = "-";
this.btOP.Text = "-";
}
private void rMult_CheckedChanged(object sender, EventArgs e)
{
this.lbOp.Text = "*";
this.btOP.Text = "*";
}
private void rDiv_CheckedChanged(object sender, EventArgs e)
{
this.lbOp.Text = "/";
this.btOP.Text = "/";
}
private void btOP_Click(object sender, EventArgs e)
{
Random rnd = new Random();
this.lbV1.Text = (rnd.Next(100)).ToString();
this.lbV2.Text = (rnd.Next(100)).ToString();
switch (this.lbOp.Text)
{
case "+":
lbResult.Text = (float.Parse(lbV1.Text) + float.Parse(lbV2.Text)).ToString();
break;
case "-":
lbResult.Text = (float.Parse(lbV1.Text) - float.Parse(lbV2.Text)).ToString();
break;
case "*":
lbResult.Text = (float.Parse(lbV1.Text) * float.Parse(lbV2.Text)).ToString();
break;
case "/":
lbResult.Text = (float.Parse(lbV1.Text) / float.Parse(lbV2.Text)).ToString();
break;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void cmdOK_Click(object sender, EventArgs e)
{
string output;
output="ID: " + txtID.Text + "\r\n";
output+= "Name: " + txtName.Text + "\r\n";
output+="Gender: " + txtGender.Text + "\r\n";
output+="DOB:" + txtDOB.Text + "\r\n";
output += "Address:" + txtGender.Text + "\r\n____________________________________\r\n";
txtOUTPUT.Text =txtOUTPUT.Text + output;
}
private void cmdHELP_Click(object sender, EventArgs e)
{
string output;
output = "ID= Your ID\r\n";
output +="Name = Your name\r\n";
output +="Sex = Your sex\r\n";
output += "Address = Your address\r\n";
output += "DOB = Your date of birth 'dd/mm/yyyy'\r\n";
// Insert the new text.
this.txtOUTPUT.Text = output;
}
}
}
//_____________________________________
private Boolean isDate(String st)
{
Boolean b = true;
try
{
DateTime dt = DateTime.Parse(st);
}
catch
{
return false;
}
return true;
}
private void textBox1_Leave(object sender, EventArgs e)
{
if (isDate(this.textBox1.Text)==false)
{
MessageBox.Show("Please, enter only date!");
this.textBox1.Focus();
}
}
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 _1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.oFD.Filter = "Windows Bitmaps|*.BMP|JPEG Files|*.JPG";
}
private void btSelect_Click(object sender, EventArgs e)
{
oFD.InitialDirectory = @"C:\";
oFD.Title = "Select a File";
this.oFD.FileName = "";
if (this.oFD.ShowDialog() == DialogResult.OK)
{
this.pBox.Image = Image.FromFile(oFD.FileName);
this.Text = String.Concat("Picture Viewer (" + oFD.FileName + ")");
this.cboPath.Items.Add(oFD.FileName);
}
}
private void btQuit_Click(object sender, EventArgs e)
{
this.Close();
}
private void cboPath_SelectedIndexChanged(object sender, EventArgs e)
{
this.pBox.Image = Image.FromFile(cboPath.Text);
}
}
}
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 _3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btEnlarge_Click(object sender, EventArgs e)
{
this.Width = this.Width + 20;
this.Height = this.Height + 20;
}
private void btShrink_Click(object sender, EventArgs e)
{
this.Width = this.Width - 20;
this.Height = this.Height - 20;
}
private void btObject_Click(object sender, EventArgs e)
{
for (int intIndex = 0; intIndex < this.Controls.Count;intIndex++)
{
MessageBox.Show("Control # " + intIndex.ToString() +" has the name " + this.Controls[intIndex].Name);
}
}
}
}
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 _5
{
public partial class Form1 : Form
{
public static string opt;
public static string u1;
public static string u2;
public Form1()
{
InitializeComponent();
}
private static double operate(string v1, string v2, string opt)
{
double result=0;
switch (opt)
{
case "+":
result = double.Parse(v1) + double.Parse(v2);
break;
case "-":
result = double.Parse(v1) - double.Parse(v2);
break;
case "*":
result = double.Parse(v1) * double.Parse(v2);
break;
case "/":
result = double.Parse(v1) - double.Parse(v2);
break;
case "Min":
result = (double.Parse(v1)> double.Parse(v2))?double.Parse(v2):double.Parse(v1);
break;
case "Max":
result = (double.Parse(v1)> double.Parse(v2))?double.Parse(v1):double.Parse(v2);
break;
}
return result;
}
private void rBSum_CheckedChanged(object sender, EventArgs e)
{
if (this.rBSum.Checked)
{
if (this.txtVal1.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី១");
this.txtVal1.Focus();
}
else if (this.txtVal2.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី២");
this.txtVal2.Focus();
}
else
{
opt = "+";
this.txtResult.Text = (operate(this.txtVal1.Text, this.txtVal2.Text, opt)).ToString();
}
}
}
private void rBMinus_CheckedChanged(object sender, EventArgs e)
{
if (this.rBMinus.Checked)
{
if (this.txtVal1.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី១");
this.txtVal1.Focus();
}
else if (this.txtVal2.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី២");
this.txtVal2.Focus();
}
else
{
opt = "-";
this.txtResult.Text = (operate(this.txtVal1.Text, this.txtVal2.Text, opt)).ToString();
}
}
}
private void rbMult_CheckedChanged(object sender, EventArgs e)
{
if (this.rbMult.Checked)
{
if (this.txtVal1.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី១");
this.txtVal1.Focus();
}
else if (this.txtVal2.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី២");
this.txtVal2.Focus();
}
else
{
opt = "*";
this.txtResult.Text = (operate(this.txtVal1.Text, this.txtVal2.Text, opt)).ToString();
}
}
}
private void rBDiv_CheckedChanged(object sender, EventArgs e)
{
if (this.rBDiv.Checked)
{
if (this.txtVal1.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី១");
this.txtVal1.Focus();
}
else if (this.txtVal2.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី២");
this.txtVal2.Focus();
}
else
{
opt = "/";
this.txtResult.Text = (operate(this.txtVal1.Text, this.txtVal2.Text, opt)).ToString();
}
}
}
private void rbMin_CheckedChanged(object sender, EventArgs e)
{
if (this.rbMin.Checked)
{
if (this.txtVal1.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី១");
this.txtVal1.Focus();
}
else if (this.txtVal2.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី២");
this.txtVal2.Focus();
}
else
{
opt = "Min";
this.txtResult.Text = (operate(this.txtVal1.Text, this.txtVal2.Text, opt)).ToString();
}
}
}
private void rBMax_CheckedChanged(object sender, EventArgs e)
{
if (this.rBMax.Checked)
{
if (this.txtVal1.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី១");
this.txtVal1.Focus();
}
else if (this.txtVal2.Text == "")
{
MessageBox.Show("សូមវាតតំលៃទី២");
this.txtVal2.Focus();
}
else
{
opt = "Max";
this.txtResult.Text = (operate(this.txtVal1.Text, this.txtVal2.Text, opt)).ToString();
}
}
}
private void chClear_CheckedChanged(object sender, EventArgs e)
{
if (this.chClear.Checked)
{
u1 = this.txtVal1.Text;
u2 = this.txtVal2.Text;
this.txtVal1.Text = "";
this.txtVal2.Text = "";
this.txtResult.Text = "";
}
}
private void chUndo_CheckedChanged(object sender, EventArgs e)
{
if (chUndo.Checked)
{
this.txtVal1.Text = u1;
this.txtVal2.Text = u2;
}
}
}
}
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 _6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btSearch_Click(object sender, EventArgs e)
{
Boolean b=false;
for (int i = 0; i < lstProduct.Items.Count; i++)
{
if (lstProduct.Items[i].ToString() == (txtProID.Text + "\t" + txtProName.Text + "\t" + txtQty.Text + "\t" + txtUnitPrice.Text + "\t" + double.Parse(txtQty.Text) * double.Parse(txtUnitPrice.Text)))
{
lstProduct.Focus();
lstProduct.SelectedIndex=i ;
b = true;
return;
}
}
if (b == false)
{
MessageBox.Show("រកមិនឃើញទេ!");
}
}
private void btInsert_Click(object sender, EventArgs e)
{
this.lstProduct.Items.Add(txtProID.Text + "\t" + txtProName.Text + "\t" + txtQty.Text + "\t" + txtUnitPrice.Text + "\t" + double.Parse(txtQty.Text)*double.Parse(txtUnitPrice.Text));
}
private void btDelete_Click(object sender, EventArgs e)
{
if (this.lstProduct.SelectedIndex!=-1)
{
//this.lstProduct.Items.Remove(this.lstProduct.Text);
this.lstProduct.Items.RemoveAt(this.lstProduct.SelectedIndex);
}
}
private static string IdProduct()
{
return "";
// for(int i=0;i<
}
private void btNew_Click(object sender, EventArgs e)
{
txtProID.Text = "";
txtProName.Text = "";
txtQty.Text = "";
txtUnitPrice.Text = "";
}
private void Form1_Load(object sender, EventArgs e)
{
this.lstProduct.Sorted = true;
}
}
}
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 _7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void TM_Tick(object sender, EventArgs e)
{
this.lbDay.BackColor = Color.AliceBlue;
DateTime objToday = DateTime.Now;
lbDay.Text = (objToday.DayOfWeek).ToString();
lbTime.Text = "Time: " + objToday.ToLongTimeString();
lbMonth.Text ="Month: " + (objToday.Month).ToString();
lbD.Text = "Day: " + (objToday.Day).ToString();
lbYear.Text = (objToday.Year).ToString();
}
}
}
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 _8
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btResult1_Click(object sender, EventArgs e)
{
int i=0;
int s=0;
while(i < 10)
{
i = i + 1;
s = s + i;
}
this.txtResult1.Text = s.ToString();
}
private void btResult2_Click(object sender, EventArgs e)
{
int i = 1;
int s = 0;
while (i < 10)
{
s = s + i;
i = i + 2;
}
this.txtResult2.Text = s.ToString();
}
private void btResult3_Click(object sender, EventArgs e)
{
int i = 2;
int s = 0;
while (i <= 10)
{
s = s + i;
i = i + 2;
}
this.txtResult3.Text = s.ToString();
}
private void tabControl1_MouseClick(object sender, MouseEventArgs e)
{
int i = 0;
double rndNum = 0;
Random rnd = new Random();
do
{
rndNum = rnd.Next(10) + 1;
cboValue.Items.Add(Math.Round(rndNum));
i = i + 1;
} while (i < 10);
}
private void btMin_Click(object sender, EventArgs e)
{
int i=0;
int min=int.Parse(cboValue.Items[0].ToString());
do
{
if(min>int.Parse(cboValue.Items[i].ToString()))
{
min=int.Parse(cboValue.Items[i].ToString());
}
i=i+1;
}while(i<cboValue.Items.Count);
txtMin.Text=min.ToString();
}
private void btMax_Click(object sender, EventArgs e)
{
int i = 0;
int max = int.Parse(cboValue.Items[0].ToString());
do
{
if (max < int.Parse(cboValue.Items[i].ToString()))
{
max = int.Parse(cboValue.Items[i].ToString());
}
i = i + 1;
} while (i < cboValue.Items.Count);
txtMax.Text = max.ToString();
}
private void btRnd_Click(object sender, EventArgs e)
{
cboValue.Items.Clear();
int i = 0;
double rndNum = 0;
Random rnd = new Random();
do
{
rndNum = rnd.Next(10) + 1;
cboValue.Items.Add(Math.Round(rndNum));
i = i + 1;
} while (i < 10);
}
}
}
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 _10
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.cboGender.Items.Add("Male");
this.cboGender.Items.Add("Female");
this.cboGender.SelectedIndex = 0;
lvwCustomer.View = View.Details;
lvwCustomer.Columns.Add("CustID", 120, HorizontalAlignment.Left);
ColumnHeader colCustName = new ColumnHeader();
colCustName.Text = "CustName";
colCustName.Width = 120;
colCustName.TextAlign = HorizontalAlignment.Right;
ColumnHeader colGender = new ColumnHeader();
colGender.Text = "Gender";
colGender.Width = 80;
colGender.TextAlign = HorizontalAlignment.Right;
ColumnHeader colDOB = new ColumnHeader();
colDOB.Text = "Date of birth";
colDOB.Width = 120;
colDOB.TextAlign = HorizontalAlignment.Right;
ColumnHeader colAddress = new ColumnHeader();
colAddress.Text = "Address";
colAddress.Width = 200;
colAddress.TextAlign = HorizontalAlignment.Right;
ColumnHeader colPhoto = new ColumnHeader();
colPhoto.Text = "Path";
colPhoto.Width = 200;
colPhoto.TextAlign = HorizontalAlignment.Left;
ColumnHeader[] cols = {colCustName , colGender,colDOB,colAddress,colPhoto};
lvwCustomer.Columns.AddRange(cols);
}
private void btClear_Click(object sender, EventArgs e)
{
this.txtCustID.Text = "";
this.txtCustName.Text = "";
this.txtAddress.Text = "";
this.txtDOB.Text = "";
}
private static string path;
private void pictureBox1_DoubleClick(object sender, EventArgs e)
{
oFD.InitialDirectory = @"C:\";
oFD.Title = "Select a File";
this.oFD.FileName = "";
if (this.oFD.ShowDialog() == DialogResult.OK)
{
this.pB.Image = Image.FromFile(oFD.FileName);
path = oFD.FileName;
}
}
private void btInsert_Click(object sender, EventArgs e)
{
ListViewItem lvicust = lvwCustomer.Items.Add(this.txtCustID.Text);
lvicust.SubItems.Add(this.txtCustName.Text);
lvicust.SubItems.Add(this.cboGender.Text);
lvicust.SubItems.Add(this.txtDOB.Text);
lvicust.SubItems.Add(this.txtAddress.Text);
lvicust.SubItems.Add(path);
}
private void btDelete_Click(object sender, EventArgs e)
{
int i;
Boolean b=false;
for (i = lvwCustomer.Items.Count-1; i >= 0; i--)
{
if (lvwCustomer.Items[i].Selected == true)
{
lvwCustomer.Items.RemoveAt(i);
b = true;
}
}
if (b == false)
{
MessageBox.Show("Cannot delete, no items te");
}
}
private void lvwCustomer_Click(object sender, EventArgs e)
{
int i;
for (i = lvwCustomer.Items.Count - 1; i >= 0; i--)
{
if (lvwCustomer.Items[i].Selected == true)
{
txtCustID.Text = lvwCustomer.Items[i].Text;
txtCustName.Text = lvwCustomer.Items[i].SubItems[1].Text;
cboGender.Text = lvwCustomer.Items[i].SubItems[2].Text;
txtDOB.Text = lvwCustomer.Items[i].SubItems[3].Text;
txtAddress.Text = lvwCustomer.Items[i].SubItems[4].Text;
this.pB.Image = Image.FromFile(lvwCustomer.Items[i].SubItems[5].Text);
break;
}
}
}
private void lvwCustomer_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void pB_Click(object sender, EventArgs e)
{
}
private void btUpdate_Click(object sender, EventArgs e)
{
int i;
Boolean b = false;
for (i = lvwCustomer.Items.Count - 1; i >= 0; i--)
{
if (lvwCustomer.Items[i].Selected == true)
{
lvwCustomer.Items[i].SubItems[1].Text = this.txtCustName.Text;
lvwCustomer.Items[i].SubItems[2].Text = this.cboGender.Text;
lvwCustomer.Items[i].SubItems[3].Text = this.txtDOB.Text;
lvwCustomer.Items[i].SubItems[4].Text = this.txtAddress.Text;
lvwCustomer.Items[i].SubItems[5].Text = path;
b = true;
}
}
if (b == false)
{
MessageBox.Show("Cannot Update te");
}
}
private void btSearch_Click(object sender, EventArgs e)
{
int i;
Boolean b = false;
for (i = lvwCustomer.Items.Count - 1; i >= 0; i--)
{
if (lvwCustomer.Items[i].Text == this.txtCustID.Text)
{
this.txtCustName.Text = lvwCustomer.Items[i].SubItems[1].Text;
this.cboGender.Text = lvwCustomer.Items[i].SubItems[2].Text;
this.txtDOB.Text=lvwCustomer.Items[i].SubItems[3].Text;
this.txtAddress.Text=lvwCustomer.Items[i].SubItems[4].Text;
this.pB.Image =Image.FromFile(lvwCustomer.Items[i].SubItems[5].Text);
b = true;
}
}
if (b == false)
{
MessageBox.Show("Cannot Update te");
}
}
}
}
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 _11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void closeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (!closeToolStripMenuItem.Checked)
{
if (MessageBox.Show("Do you really wish to exit?","QuitVerification",MessageBoxButtons.YesNo) ==DialogResult.No)
return;
}
this.Close();
}
private void Form1_Load(object sender, EventArgs e)
{
closeToolStripMenuItem.Checked = (!closeToolStripMenuItem.Checked);
}
}
}