Hi All ,
In my listBox have line count and data.I want show in listBox2 items is line only without the data.
Line 0 to 7.In listbox show" 2 and 3" or " 1,2 and 3".
I want use IndexOf code to remove that Data.
Text File;=7508,7989,5177,5894,8711,5618,7784,0772,1148,2302,3007,0445,7829,5254,0672,6012,2931,8558,9004,8286,4251,3918,4525
3142,8140,0147,1022,9497,6486,2969,3132,1470,5048,0440,0720,3074,2699,5176,7436,0573,6838,3996,2816,5044,0842,2215
6777,0370,0622,5686,7406,5002,8392,1134,8105,3722,8120,7627,9722,9637,2796,6892,2386,2467,8991,3882,8678,3000,2243
9833,3856,8514,5533,4623,4715,6821,2943,4246,4592,8990,2299,3000,1630,1635,1426,7648,8883,9426,1357,0309,7176,2005
1510,4365,6184,3709,2544,8940,3138,6743,0193,6703,2157,3618,4561,7326,6067,1156,6705,8319,4406,3085,8871,0661,9861
8403,1980,5490,7606,6127,6431,4916,0421,0111,0495,9858,0020,8117,2913,6913,8912,1929,9174,1653,0722,2143,2283,6557
2895,3572,9580,2712,3854,7385,2866,1925,8168,3931,8140,1541,3263,2393,5656,9860,4136,8550,7844,2627,1576,5170,2300
1109,7796,6815,2226,1854,1001,7718,0956,3157,4504,2122,2151,0788,9371,1838,1155,9435,0502,1337,7646,0096,0757,6351
Here is code test;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ListB_1
{
public partial class Form1 : Form
{
List<string> Data1 = new List<string>();
List<string> Data2 = new List<string>();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int linecount = 0;
foreach (var s in File.ReadLines(@"C:\Users\family\Documents\Ahad.txt"))
{
listBox1.Items.Add(linecount++ + " " + s);
Data1.Add(linecount.ToString() + " " + s);
}
}
private void button1_Click(object sender, EventArgs e)
{
string a = "";
string b = "";
for (int i = 0; i < listBox1.Items.Count; i++)
{
a = listBox1.Items[5].ToString();
b = listBox1.Items[6].ToString();
}
listBox2.Items.Add(a);
listBox2.Items.Add(b);
}
private void button2_Click(object sender, EventArgs e)
{
}
}
}
Hi JackJJun,
Yes Let "linecount " , Remove the Data at back position.Using IndexOf.
ListBox2 show; Example
2 and 3 or
2,4 and 6. or
dll.
For future I prepare click in ListBox2 get back my Data.
Thank Jack.