テキストラベルで特定の単語を見つけて太字にする方法を知りたい。たとえばdescriptionTxt.Text
についてはC#で特定の単語を太字にする
が含まれているいくつかの単語「ステップ1 :,ステップ2:のように...
私はスペースが続くリテラルテキスト 『ステップ』を、検索する、1つのまたは複数の数字、コロン」と、これが太字に。
C#コード
protected void Page_Load(object sender, EventArgs e)
{
string ID = Request.QueryString["id"];
RecipeID.Text = ID;
SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\v11.0; AttachDbFilename=C:\Users\Donald\Documents\Visual Studio 2013\Projects\DesktopApplication\DesktopApplication\Student_CB.mdf ;Integrated Security=True");
con.Open();
try
{
SqlDataAdapter sda = new SqlDataAdapter("Select Recipe_Name, Recipe_Description, Recipe_Instructions FROM Recipe Where Recipe_ID= @recipeid", con);
sda.SelectCommand.Parameters.Add("@recipeid", SqlDbType.Int).Value = RecipeID.Text;
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count > 0)
nameTxt.Text = dt.Rows[0][0].ToString();
descriptionTxt.Text = dt.Rows[0][1].ToString();
instructionsTxt.Text = dt.Rows[0][2].ToString();
dt.Clear();
}
catch (Exception ex)
{
}
con.Close();
}
_ "これらを見つけたい" _ - define ** these **。太字にしたい単語を英語で定義できたら、それをコードに変換するのは簡単です。 – CodeCaster
「etc」とはどういう意味ですか、**正確には**ですか?具体的にしてください。何を試しましたか? ''ステップ[0-9] +: ''のような正規表現は、あなたが望むことをするようです... – CodeCaster
@CodeCasterエテトラが何を意味するのか分かりませんか?その手段はそうであり、それは第四です。リストのように続けます。ステップ1、ステップ2、ステップ3、ステップ4、ステップ5、ステップ6、ステップ7に進みます。 –