Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

autocomplete textbox from listbox

$
0
0

Hi,

I have a code here but I'm having 1 error ..

here's the code

private void InsertCitationForm_Load(object sender, EventArgs e)
        {
            Word.Application App = Globals.ThisAddIn.Application;
            Word.Document doc = App.ActiveDocument;
            Word.Sources sour = doc.Bibliography.Sources;
           items.AddRange(new object[] { sour });

           foreach (object str in items)
            {
                listBox1.Items.Add(str);
            }
        }


List<object> items = new List<object>();

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            listBox1.Items.Clear();

            foreach (object str in items)
            {
               if (str.StartsWith(textBox1.Text, StringComparison.CurrentCultureIgnoreCase))
                {
                   listBox1.Items.Add(str);
                }
            }
        }

and this line have an error

if (str.StartsWith(textBox1.Text, StringComparison.CurrentCultureIgnoreCase))

Error	1	'object' does not contain a definition for 'StartsWith' and no extension method 'StartsWith' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

by the way the items in the listbox is the current list of the active document

i hope someone can fix this error



Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>