Page 1 of 2
FlowLayoutPanel.
Posted: Mon Feb 02, 2015 5:16 pm
by Dummy1912
Hello,
I was wondering if someone can help us out (
we use vb 2013 .net)
we have a few controls into this flowlayoutpanel
and we have a textbox that we wanna use for search.
So we like to get the current search of the textbox that maybe exist in the flowlayoutpanel
when we search for a Description and if the flowlayoutpanel contains the controls that has the Description then it will remove the rest and show only that part that has the Description
with short words we like to create a search part to get the controls that has this description of the search.
for example we have 100 Controls
and with different descriptions
Codenstuff Test
Danny Demo
Flow by me
Duck
Cat
Mouse
and when we type into the textbox : D or Danny Demo
it will show only the controls that has the textbox search.
hope this helps
Thank you.
Re: FlowLayoutPanel.
Posted: Mon Feb 02, 2015 11:13 pm
by CodenStuff
This may help.
Using a textbox to search for a specific control by name, example "Button4", it will display a message box with the contorls Tag property if it finds it.
Code: Select allDim FLControls As Control() = FlowLayoutPanel1.Controls.Find(TextBox1.Text, False)
For Each FLC As Control In FLControls
MsgBox(FLC.Tag)
Next
Re: FlowLayoutPanel.
Posted: Tue Feb 03, 2015 5:05 am
by Dummy1912
Hi #CodenStuff
Thanks for the reply
i will look into it and keep you posted
Thanks loove;
Re: FlowLayoutPanel.
Posted: Tue Feb 03, 2015 4:59 pm
by Dummy1912
Hello Again,
I have tested it but isn't working
is it possible to get from the control his label.text to search on?
Code: Select all' the control is
Dim FLControls As MetroDetailBar() = BorderPanel1.Controls.Find(txtsearch.Text, False)
thanks
Re: FlowLayoutPanel.
Posted: Tue Feb 03, 2015 7:47 pm
by comathi
According to MSDN's documentation, the Find() method finds controls by name, if you want to search controls according to text in one of their labels, it'll be a bit more complicated, but it's still possible in theory.
However, I suggest that instead, you dynamically change the name of your controls when you add them to your FlowLayoutPanel so that you can use the function Craig posted... it's probably much more efficient than any method with labels cooll;
Re: FlowLayoutPanel.
Posted: Tue Feb 03, 2015 8:54 pm
by Smiley
Hi Dummy give this little test app a look and let me know if it helps
flowlayoutsearh.zip
Smiley cooll;
Re: FlowLayoutPanel.
Posted: Wed Feb 04, 2015 5:09 am
by Dummy1912
Thanks my dear #Smiley
i keep you posted ;)
Re: FlowLayoutPanel.
Posted: Wed Feb 04, 2015 5:05 pm
by Dummy1912
sorry #Smiley,
but does not work
all controls has been loaded but search dpn't work
even with a msgbox as result no popup :(
Code: Select allPrivate Sub btnsearch_Click(sender As Object, e As EventArgs) Handles btnsearch.Click
Try
'Dim FLControls As MetroDetailBar() = BorderPanel1.Controls.Find(txtsearch.Text, False)
'For Each FLC As MetroDetailBar In FLControls
' MsgBox(FLC.Text)
'Next
Dim match As Boolean = False
For Each item As MetroDetailBar In BorderPanel1.Controls
If item.Text = txtsearch.Text Then
match = True
End If
Next
If match = True Then
For Each del As MetroDetailBar In BorderPanel1.Controls
If del.Text = txtsearch.Text Then
MsgBox(del.Text)
Else
del.Dispose()
End If
Next
End If
Catch ex As Exception
Exit Sub
End Try
End Sub
Re: FlowLayoutPanel.
Posted: Thu Feb 05, 2015 2:25 am
by Smiley
Dummy1912 wrote:sorry #Smiley,
but does not work
all controls has been loaded but search dpn't work
even with a msgbox as result no popup :(
Code: Select allPrivate Sub btnsearch_Click(sender As Object, e As EventArgs) Handles btnsearch.Click
Try
'Dim FLControls As MetroDetailBar() = BorderPanel1.Controls.Find(txtsearch.Text, False)
'For Each FLC As MetroDetailBar In FLControls
' MsgBox(FLC.Text)
'Next
Dim match As Boolean = False
For Each item As MetroDetailBar In BorderPanel1.Controls
If item.Text = txtsearch.Text Then
match = True
End If
Next
If match = True Then
For Each del As MetroDetailBar In BorderPanel1.Controls
If del.Text = txtsearch.Text Then
MsgBox(del.Text)
Else
del.Dispose()
End If
Next
End If
Catch ex As Exception
Exit Sub
End Try
End Sub
When you add the controls make sure each MetroDetailbar.Tag = "whatever item it is"
then change the if statements to check for item tag instead of item text.
If that doesnt work i would be happy to take a look at the source to the application your building.
Smiley, cooll;
Re: FlowLayoutPanel.
Posted: Thu Feb 05, 2015 4:47 am
by Dummy1912
Sorry #Smiley
but this didn't worked :(