Click here to Skip to main content
15,895,709 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I've added the feature of autocomplete in my application with following lines of code but the autocomplete text came in the default font. how to specify another font in this scenario. Suggest me the way tackle this problem. Thanx in advance.
-Satyam
C#
public string strConnection = ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ConnectionString.ToString();
AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();

public Form1()
{
    InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
    MySqlDataReader dReader;
    MySqlConnection conn = new MySqlConnection();
    conn.ConnectionString = strConnection;
    MySqlCommand cmd = new MySqlCommand();
    cmd.Connection = conn;
    cmd.CommandText = "select name from VDCMunicipalityInfo";
    conn.Open();
    dReader = cmd.ExecuteReader();
    if (dReader.HasRows == true)
    {
        while (dReader.Read())
            namesCollection.Add(dReader["name"].ToString());
    }
    else
    {
        MessageBox.Show("Data not found");
    }
    dReader.Close();
    txtName.AutoCompleteMode = AutoCompleteMode.Suggest;
    txtName.AutoCompleteSource = AutoCompleteSource.CustomSource;
    txtName.AutoCompleteCustomSource = namesCollection;
}
Posted
Updated 22-Feb-10 1:42am
v2

Try setting the property txtName.Font
 
Share this answer
 
v2
Comments
Sandeep Mewara 4-Feb-11 2:28am    
Comment from OP:
I did specified the required font in the UI design mode but it didn't helped the situation; the font was not applied to the autocomplete suggestion text. Please give me another solution.Thanx in advance.
-satyam
This cannot be done. The OS does not expose a method to set the font of the auto complete pop-up. You would have to roll your own auto complete function to do this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900