I am using treelistview from brightideassoftware and want to select a specific child in my treelist.
The type of my object is 'MeasurementFile'.
public class MeasurementFile
{
private string fileName = string.Empty;
private List<SignalObjects> signals = new List<SignalObjects>();
...
}
The type of the children is 'SelectObjects':
public class SignalObjects
{
private string signalName = string.Empty;
public SignalObjects(string signalName)
{
this.signalName = signalName;
}
public string SignalName { get { return signalName; } }
}
So each MeasurementFile does have a list of signals.
My treelistview looks like:
MyWinForm:
name/signal //Column
-myFile1
|_____signal1
|_____signal2
|_____signal3
-myFile2
-myFile3
-myFile4
Now i want so search after a specific child. If the MeasurementFileobject is expanded and i enter something in my searchTextEdit, all matched children should be selected. If i enter "al1" in my searchbar, the child with the name "signal1" should be selected.
My question is: How can i select the matched children?
I tried ...
private void searchSignalTextEdit_TextChanged(object sender, EventArgs e)
{
string text = searchSignalTextEdit.Text;
if (!String.IsNullOrEmpty(text))
{
foreach (MeasurementFile measurementFile in treeListView1.Objects)
{
if (treeListView1.IsExpanded(measurementFile))
{
foreach (SignalObjects signal in measurementFile.getSignals)
{
if (signal.SignalName.Contains(text))
{
treeListView1.SelectObject(signal);
}
}
}
}
}
}
... but nothing was been selected. I would be glad if anybody can help me :)
Use linq and regular expressions something like: