Wowywow
Member
- Joined
- Nov 9, 2019
- Messages
- 16
- Programming Experience
- Beginner
Right, so I've been trying to figure out this exercise for a few days now and I really can't come up with anything, just the pure basics.
	
	
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
What I'am pretty much doing is generating comboBox.Items when user clicks on the comboBox and unsubscribing from event, so I wouldn't just get many copies of said items. From there I need to make it so that when they choose any of those items data related to them would be loaded into the dataGridview and I get stuck here. The data in file follows this format: Item name: its dimensions, amount of it left: dimensions, amount: dimensions, amount: ... and so on. What happens that I load up data from 3 different items data and not the different dimensions or amounts that I need.
If you can please keep the code or any technical stuff simple, so I could understand. Thanks.
	
		
			
		
		
	
				
			
			
				C#:
			
		
		
		using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void comboBox1_Click(object sender, EventArgs e)
        {
            string filePath = System.IO.Directory.GetCurrentDirectory() + @"\txt1.txt";
            using (var streamReader = new System.IO.StreamReader(filePath))
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    string[] index = line.Split('\t');
                    for(int i=0; i<index.Length; i++)
                    {
                        string[] prekPav = index[i].Split(':');
                        comboBox1.Items.Add(prekPav[i]);
                        comboBox1.Click -= comboBox1_Click;
                    }
                }
            }
        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string filePath = System.IO.Directory.GetCurrentDirectory() + @"\txt1.txt";
            using (var streamReader = new System.IO.StreamReader(filePath))
            {
                while (!streamReader.EndOfStream)
                {
                    string line = streamReader.ReadLine();
                    string[] index = line.Split('\t');
                    for (int i = 0; i < index.Length; i++)
                    {
                        string[] prek = index[i].Split(':');
                        string[] mat = prek[i+1].Split(',');
                        string[] kiek = prek[i+1].Split(':');
                        kiek[i] = kiek[i].Replace(mat[i] + ",", "");
                    }
                }
            }
        }
    }
}If you can please keep the code or any technical stuff simple, so I could understand. Thanks.
 
	 
 
		 
 
		
 
 
		 
 
		