I'm looking to do something in C# but just not sure of the syntax.
I return a string
from a database and want to check if that string
is present an开发者_JAVA技巧ywhere in a TextBox
.
How do I do this?
I think I understand your question.
You can use the Contains method to test if your string is contained within the textbox value
TextBox1.Text.Contains(yourString)
Probably this is too obvious?:
if ( myTextBox.Text.Contains(myStringFromDB) )
{
// Is contained, do something...
}
else
{
// Is not contained, do something else...
}
For Windows Forms, see this TextBox
class, for Web Forms see this TextBox
class.
精彩评论