Professional Documents
Culture Documents
000 Pit4 Beskonekciono Okruzenje
000 Pit4 Beskonekciono Okruzenje
Kreirati nov projekat pod Visual Studio 2022 sa templejtom Windows Forms App(.NET
Framework).
Projekat nazvati AppMalaBP.
Dodati na formu komponentu ListView, promeniti joj ime u lista, font u Tahoma, 12pt.
Dodati lejbel na formu i promeniti ime u lejbel1, font u Tahoma, bold, 16pt, Text u ID:
Dodati jednu komponentu tekstboks na formu i promeniti naziv komponente u tekstboks1, font
u Tahoma, bold, 12pt.
Iskopirati napravljeni tekstboks u tri primerka, promeniti im nazive u tekstboks2, tekstboks3 i
tekstboks4:
namespace AppMalaBP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
}
Uneti sledeći kod u metodu:
private void Form1_Load(object sender, EventArgs e)
{
lista.Columns.Add("id", 100);
lista.Columns.Add("ime", 200);
lista.Columns.Add("prezime", 200);
lista.Columns.Add("bodovi", 100);
}
Time se dobija:
Na formu dodati prvo dugme pod imenom dugme1, font u Tahoma, bold, 20pt, Text u DODATI
ZAPIS:
namespace AppMalaBP
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
Form1.cs
using System;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace AppMalaBP
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
lista.Columns.Add("id", 100);
lista.Columns.Add("ime", 200);
lista.Columns.Add("prezime", 200);
lista.Columns.Add("bodovi", 100);
}
private void Dugme1_Klik(object sender, EventArgs e)
{
ListViewItem podatak = new ListViewItem(tekstboks1.Text);
podatak.SubItems.Add(tekstboks2.Text);
podatak.SubItems.Add(tekstboks3.Text);
podatak.SubItems.Add(tekstboks4.Text);
lista.Items.Add(podatak);
}
private void Dugme2_Klik(object sender, EventArgs e)
{
tekstboks1.Text = "";
tekstboks2.Text = "";
tekstboks3.Text = "";
tekstboks4.Text = "";
}
private void Lista_Klik(object sender, EventArgs e)
{
if (lista.SelectedItems.Count > 0)
{
tekstboks1.Text = lista.SelectedItems[0].SubItems[0].Text;
tekstboks2.Text = lista.SelectedItems[0].SubItems[1].Text;
tekstboks3.Text = lista.SelectedItems[0].SubItems[2].Text;
tekstboks4.Text = lista.SelectedItems[0].SubItems[3].Text;
}
}
private void Dugme3_Klik(object sender, EventArgs e)
{
if (lista.SelectedItems.Count > 0)
{
lista.SelectedItems[0].SubItems[0].Text = tekstboks1.Text;
lista.SelectedItems[0].SubItems[1].Text = tekstboks2.Text;
lista.SelectedItems[0].SubItems[2].Text = tekstboks3.Text;
lista.SelectedItems[0].SubItems[3].Text = tekstboks4.Text;
}
}
private void Dugme4_Klik(object sender, EventArgs e)
{
if(lista.SelectedItems.Count > 0)
{
lista.Items.Remove(lista.SelectedItems[0]);
}
}
private void Dugme5_Klik(object sender, EventArgs e)
{
lista.Items.Clear();
}
}
}
Form1.Designer.cs
namespace AppMalaBP
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed;
otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lista = new System.Windows.Forms.ListView();
this.lejbel1 = new System.Windows.Forms.Label();
this.lejbel2 = new System.Windows.Forms.Label();
this.lejbel3 = new System.Windows.Forms.Label();
this.lejbel4 = new System.Windows.Forms.Label();
this.tekstboks1 = new System.Windows.Forms.TextBox();
this.tekstboks2 = new System.Windows.Forms.TextBox();
this.tekstboks3 = new System.Windows.Forms.TextBox();
this.tekstboks4 = new System.Windows.Forms.TextBox();
this.dugme1 = new System.Windows.Forms.Button();
this.dugme2 = new System.Windows.Forms.Button();
this.dugme3 = new System.Windows.Forms.Button();
this.dugme4 = new System.Windows.Forms.Button();
this.dugme5 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// lista
//
this.lista.Font = new System.Drawing.Font("Tahoma", 12F,
System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lista.GridLines = true;
this.lista.HideSelection = false;
this.lista.Location = new System.Drawing.Point(447, 41);
this.lista.Name = "lista";
this.lista.Size = new System.Drawing.Size(741, 327);
this.lista.TabIndex = 0;
this.lista.UseCompatibleStateImageBehavior = false;
this.lista.View = System.Windows.Forms.View.Details;
this.lista.Click += new System.EventHandler(this.Lista_Klik);
//
// lejbel1
//
this.lejbel1.AutoSize = true;
this.lejbel1.Font = new System.Drawing.Font("Tahoma", 15.75F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lejbel1.Location = new System.Drawing.Point(55, 41);
this.lejbel1.Name = "lejbel1";
this.lejbel1.Size = new System.Drawing.Size(38, 25);
this.lejbel1.TabIndex = 1;
this.lejbel1.Text = "ID";
//
// lejbel2
//
this.lejbel2.AutoSize = true;
this.lejbel2.Font = new System.Drawing.Font("Tahoma", 15.75F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lejbel2.Location = new System.Drawing.Point(55, 94);
this.lejbel2.Name = "lejbel2";
this.lejbel2.Size = new System.Drawing.Size(54, 25);
this.lejbel2.TabIndex = 2;
this.lejbel2.Text = "Ime";
//
// lejbel3
//
this.lejbel3.AutoSize = true;
this.lejbel3.Font = new System.Drawing.Font("Tahoma", 15.75F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lejbel3.Location = new System.Drawing.Point(55, 152);
this.lejbel3.Name = "lejbel3";
this.lejbel3.Size = new System.Drawing.Size(96, 25);
this.lejbel3.TabIndex = 3;
this.lejbel3.Text = "Prezime";
//
// lejbel4
//
this.lejbel4.AutoSize = true;
this.lejbel4.Font = new System.Drawing.Font("Tahoma", 15.75F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lejbel4.Location = new System.Drawing.Point(55, 216);
this.lejbel4.Name = "lejbel4";
this.lejbel4.Size = new System.Drawing.Size(83, 25);
this.lejbel4.TabIndex = 4;
this.lejbel4.Text = "Bodovi";
//
// tekstboks1
//
this.tekstboks1.Font = new System.Drawing.Font("Tahoma", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tekstboks1.Location = new System.Drawing.Point(197, 39);
this.tekstboks1.Name = "tekstboks1";
this.tekstboks1.Size = new System.Drawing.Size(200, 27);
this.tekstboks1.TabIndex = 5;
//
// tekstboks2
//
this.tekstboks2.Font = new System.Drawing.Font("Tahoma", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tekstboks2.Location = new System.Drawing.Point(197, 92);
this.tekstboks2.Name = "tekstboks2";
this.tekstboks2.Size = new System.Drawing.Size(200, 27);
this.tekstboks2.TabIndex = 6;
//
// tekstboks3
//
this.tekstboks3.Font = new System.Drawing.Font("Tahoma", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tekstboks3.Location = new System.Drawing.Point(197, 150);
this.tekstboks3.Name = "tekstboks3";
this.tekstboks3.Size = new System.Drawing.Size(200, 27);
this.tekstboks3.TabIndex = 7;
//
// tekstboks4
//
this.tekstboks4.Font = new System.Drawing.Font("Tahoma", 12F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.tekstboks4.Location = new System.Drawing.Point(197, 214);
this.tekstboks4.Name = "tekstboks4";
this.tekstboks4.Size = new System.Drawing.Size(200, 27);
this.tekstboks4.TabIndex = 8;
//
// dugme1
//
this.dugme1.Font = new System.Drawing.Font("Tahoma", 20.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dugme1.Location = new System.Drawing.Point(60, 411);
this.dugme1.Name = "dugme1";
this.dugme1.Size = new System.Drawing.Size(136, 80);
this.dugme1.TabIndex = 9;
this.dugme1.Text = "DODATI ZAPIS";
this.dugme1.UseVisualStyleBackColor = true;
this.dugme1.Click += new System.EventHandler(this.Dugme1_Klik);
//
// dugme2
//
this.dugme2.Font = new System.Drawing.Font("Tahoma", 20.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dugme2.Location = new System.Drawing.Point(261, 411);
this.dugme2.Name = "dugme2";
this.dugme2.Size = new System.Drawing.Size(136, 80);
this.dugme2.TabIndex = 10;
this.dugme2.Text = "NOV ZAPIS";
this.dugme2.UseVisualStyleBackColor = true;
this.dugme2.Click += new System.EventHandler(this.Dugme2_Klik);
//
// dugme3
//
this.dugme3.Font = new System.Drawing.Font("Tahoma", 20.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dugme3.Location = new System.Drawing.Point(447, 411);
this.dugme3.Name = "dugme3";
this.dugme3.Size = new System.Drawing.Size(190, 80);
this.dugme3.TabIndex = 11;
this.dugme3.Text = "PROMENITI ZAPIS";
this.dugme3.UseVisualStyleBackColor = true;
this.dugme3.Click += new System.EventHandler(this.Dugme3_Klik);
//
// dugme4
//
this.dugme4.Font = new System.Drawing.Font("Tahoma", 20.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dugme4.Location = new System.Drawing.Point(702, 411);
this.dugme4.Name = "dugme4";
this.dugme4.Size = new System.Drawing.Size(165, 80);
this.dugme4.TabIndex = 12;
this.dugme4.Text = "OBRISATI ZAPIS";
this.dugme4.UseVisualStyleBackColor = true;
this.dugme4.Click += new System.EventHandler(this.Dugme4_Klik);
//
// dugme5
//
this.dugme5.Font = new System.Drawing.Font("Tahoma", 20.25F,
System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.dugme5.Location = new System.Drawing.Point(929, 411);
this.dugme5.Name = "dugme5";
this.dugme5.Size = new System.Drawing.Size(210, 80);
this.dugme5.TabIndex = 13;
this.dugme5.Text = "OBRISATI SVE ZAPISE";
this.dugme5.UseVisualStyleBackColor = true;
this.dugme5.Click += new System.EventHandler(this.Dugme5_Klik);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1215, 560);
this.Controls.Add(this.dugme5);
this.Controls.Add(this.dugme4);
this.Controls.Add(this.dugme3);
this.Controls.Add(this.dugme2);
this.Controls.Add(this.dugme1);
this.Controls.Add(this.tekstboks4);
this.Controls.Add(this.tekstboks3);
this.Controls.Add(this.tekstboks2);
this.Controls.Add(this.tekstboks1);
this.Controls.Add(this.lejbel4);
this.Controls.Add(this.lejbel3);
this.Controls.Add(this.lejbel2);
this.Controls.Add(this.lejbel1);
this.Controls.Add(this.lista);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion