Hello guys, i am a beginer in c#. if i type one letter in text box needs to get all the file names starts with that letter into text box in c# windows application . i want to get the all file names from the directory into the text box in win forms app.. I am giving you the code can u please correct it.please. i am giving the code can you please corret it it is very urgent to me please
[using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.IO;
namespace WindowsFormsApp lication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
private void Form1_Load(obje ct sender, EventArgs e)
{
// Create the list to use as the custom source.
var source = new AutoCompleteStr ingCollection() ;
AddRange(Direct oryInfo File = @"D:\gopinath\D ATES");
foreach (FileInfo fi in File.getfiles)
{
textBox = fi.Name.Tostrin g(); //it will show the name in the text box
};
//source.AddRange (Directory.GetF iles(@"D:\gopin ath\DATES", SearchOption.Al lDirectories));
// source.AddRange (new string[]
// {
// "January",
// "February",
// "March",
// "April",
// "May",
// "June",
// "July",
// "August",
// "September" ,
// "October",
// "November",
// "December"
// });
// Create and initialize the text box.
var textBox = new TextBox
{
AutoCompleteCus tomSource = source,
AutoCompleteMod e=
AutoCompleteMod e.SuggestAppend ,
AutoCompleteSou rce =
AutoCompleteSou rce.CustomSourc e,
Location = new Point(20, 20),
Width = ClientRectangle .Width - 40,
Visible = true
};
// Add the text box to the form.
Controls.Add(te xtBox);
}
}
}
]
[using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.IO;
namespace WindowsFormsApp lication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
private void Form1_Load(obje ct sender, EventArgs e)
{
// Create the list to use as the custom source.
var source = new AutoCompleteStr ingCollection() ;
AddRange(Direct oryInfo File = @"D:\gopinath\D ATES");
foreach (FileInfo fi in File.getfiles)
{
textBox = fi.Name.Tostrin g(); //it will show the name in the text box
};
//source.AddRange (Directory.GetF iles(@"D:\gopin ath\DATES", SearchOption.Al lDirectories));
// source.AddRange (new string[]
// {
// "January",
// "February",
// "March",
// "April",
// "May",
// "June",
// "July",
// "August",
// "September" ,
// "October",
// "November",
// "December"
// });
// Create and initialize the text box.
var textBox = new TextBox
{
AutoCompleteCus tomSource = source,
AutoCompleteMod e=
AutoCompleteMod e.SuggestAppend ,
AutoCompleteSou rce =
AutoCompleteSou rce.CustomSourc e,
Location = new Point(20, 20),
Width = ClientRectangle .Width - 40,
Visible = true
};
// Add the text box to the form.
Controls.Add(te xtBox);
}
}
}
]
Comment