|
-
November 29th, 2008, 05:48 AM
#1
working with text file
Hi all
i have to rewirte the content of the text file
my text file look like below
BBC|1045|132|some text
BBC|1045|134|some text
BBC|1045|136|some text
BBK|1047|134|some text
BBK|1047|138|some text
BBK|1047|142|some text
i have to show up the first one BBC in one combo box based on selection need to show the
third parameter in another combo box , based on second combo box selection need to show the "some text" in a text box
there in text box user can change the text and click to save and the text file should be updated
which one is the bset approach to get unique names of first column to show in combo box
Thanks a lot
-
November 29th, 2008, 08:18 AM
#2
Re: working with text file
I'd use a Dictionary, List or simply a String array, combined with a class to contain lists of the rest.
Sincerely,
Martin Svendsen
-
November 29th, 2008, 08:47 AM
#3
Re: working with text file
your file structrue is Many-to-One relationship and it is not optimize for updating and retriving data.
also you have duplicated name in the second column base on them you should have a control (or bunch of them) in your form to show all related text to the second column.
IMHO it would be better that you change your data structure and them implement something like primary or foreign keys with two files like relational databases. or you can implement an combination of arrays and Link List.
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
December 1st, 2008, 12:06 AM
#4
Re: working with text file
Thanks for your replies
Could you pls show me with some piece of code
is the multi dimensional array is the correct approach
-
December 2nd, 2008, 05:33 AM
#5
Re: working with text file
yes, somewhat you can implement it with Multi Dimensional Array. or ArrayList of ArrayList to have more flexibility for add and remove and extending the lenght.
Please rate my post if it was helpful for you.  Java, C#, C++, PHP, ASP.NET
SQL Server, MySQL
DirectX
MATH Touraj Ebrahimi
[toraj_e] [at] [yahoo] [dot] [com]
-
December 3rd, 2008, 12:49 AM
#6
Re: working with text file
Code:
private void btnLoadFile_Click(object sender, EventArgs e)
{
ArrayList arrProdname = new ArrayList();
ArrayList arrProdParam = new ArrayList();
ArrayList arrProdParamVal = new ArrayList();
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.Filter = "txt files (*.txt)|*.txt";
openFileDialog1.FilterIndex = 2;
openFileDialog1.RestoreDirectory = true;
XmlDocument doc = new XmlDocument();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string fileName = openFileDialog1.FileName;
try
{
using (StreamReader sr = new StreamReader(fileName))
{
String line;
while ((line = sr.ReadLine()) != null)
{
string prdName = "";
string prdid = "";
string prdparameter = "";
string prdParamValue = "";
char[] delimiterChars = { '|' };
string[] words = line.Split(delimiterChars);
prdName = words[0];
prdid = words[1];
prdparameter = words[2];
prdParamValue = words[3];
// MessageBox.Show(line);
// cmbProductList.Items.Add(prdName);
arrProdname.Add(prdName);
arrProdParam.Add(prdparameter);
arrProdParamVal.Add(prdParamValue);
}
sr.Close();
}
}
catch (Exception ex)
{
// Let the user know what went wrong.
MessageBox.Show(ex.Message);
}
}
}
i got values into arraylists
productname into arrprodname
productparametr into arrProdParam
prodparamtervalue into arrProdParamval
but how can i get distinct value into combo box from arrprodname
and if i select a value from combo box how can i get perticular paramters for this selected product
thanks a lot
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|