[Gtk-sharp-list] Searching a specific string in a TreeStore?

Andrew York andy at brdstudio.net
Fri Apr 9 17:40:45 EDT 2010


I mormally set the search for value at the class level then check for it 
in the TreeModelForeachFunct like this:
         public void DoSearch(string searchstring)
         {
             _SearchForValue = searchstring;
             MyListStore.Foreach(new TreeModelForeachFunc(ForeachSearch));
         }

         private string _SearchForValue = string.Empty;
         private int _SearchColumn = 1;
         private bool ForeachSearch(Gtk.TreeModel model, Gtk.TreePath 
path, Gtk.TreeIter iter)
         {
             if(_SearchForValue == MyListStore.GetValue(iter, 
_SearchColumn).ToString())
             {
                 // do what you need to do with the found value or row
                 return true;
             }
             return false;
         }

On 2/27/2010 5:17 AM, IllNatured wrote:
> I want to run through a TreeStrore which contains strings and check if a
> specific string already exists. I think I should use the Foreach function
> but the TreeModelForeachFunc only accepts specific parameters so I cannot
> send the string which I want to check. What should I do?
>    






More information about the Gtk-sharp-list mailing list