Hi

I've have a Windows form application, that provieds users to add/see and search new items, items are saved into a text file with a help of streamreader/streamwriter.

My application is almost finished, but i dont know how to make a search system.


This is my application:

http://www.youtube.com/watch?v=Idgw52iXLRk&feature=plcp&context=C352918eUDOEgsToPDskIF-q5mZ0uP5UIRlBTolHbg

Code:

This is the code for the display the data that is saved into .txt file

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;
using System.IO;
using System.Collections;


namespace Lekarna
{
    public partial class Izpis_zravil : Form
    {
        int vrstice;

        public Izpis_zravil()
        {
            InitializeComponent();

            Vel();

            string[] polje = new string[100];

            ListViewItem item1 = new ListViewItem();

            string filename = "zdravila.txt";
            if (File.Exists(filename))
            {
                string[] lines = File.ReadAllLines(filename);
                for (int j = 0; j < vrstice; j++)
                {
                    polje[j] = lines[j];

                    if (j % 5 == 0)
                    {
                        item1 = new ListViewItem(polje[j]);
                        listView1.Items.AddRange(new ListViewItem[] { item1 });
                    }
                    else
                        item1.SubItems.Add(polje[j]);

                }
            }
        }

        public string Vel()
        {
            StreamReader beri = File.OpenText("zdravila.txt");
            string input = null;
            while ((input = beri.ReadLine()) != null)
            {
                vrstice++;
            }
            beri.Close();
            this.Invalidate();
            return "";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}

This is the code for saving the items

private void button1_Click_1(object sender, EventArgs e)
        {
            
            FileInfo fi = new FileInfo("zdravila.txt");
            using (StreamWriter sw = fi.AppendText())
            {
                sw.WriteLine(textBox1.Text);
                sw.WriteLine(textBox2.Text);
                sw.WriteLine(textBox5.Text);
                sw.WriteLine(textBox3.Text);
                sw.WriteLine(textBox4.Text);
            }
            MessageBox.Show("Zdravilo shranjeno!");
        
        }

Sorry for my bad english.Thanks for helping :)

Anybody? :S

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.