如何更改字符串的字体? [英] how to change a string's font?

查看:138
本文介绍了如何更改字符串的字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在制作一个基于APA网络的引文生成器.一切都很好,但是我似乎无法使字符串具有斜体字体,这是我的代码.

Hi, I am making an APA web based citation generator. All is well but I seem to be having trouble making a string have an Italic font, Here is my code.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string author;
        string date;
        string TitleOfArticle;
        string Retriveddate;
        string websiteURl;
        string citation;

        private void Form1_Load(object sender, EventArgs e)
        {
            AuthorBox.Items.Add("unidentified");
            PublishBox.Items.Add("n.d");

            TitleBox.Text.Equals(Font.Italic);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //issues: make the richtextbox display title as italic.

            author = AuthorBox.Text;
            date = PublishBox.Text;
            TitleOfArticle = TitleBox.Text;
            Retriveddate = RetrivedBox.Text;
            websiteURl = URLBox.Text;
            citation = author + " ." + "(" + date + "). " + TitleOfArticle + ". Retrieved " + Retriveddate + ", from " + websiteURl;
            richTextBox1.Text = citation;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            richTextBox1.Copy();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            richTextBox1.Clear();
        }
    }
}


如您在示例代码中所看到的,我为每个组合框都有字符串,并且它们记录了每个框的用户输入.然后,我将所有这些组合在一起,并将其放入1个称为引文"的字符串中,当用户按下按钮时,该字符串将显示在Richtextbox中.在对APA进行适当的网络引用时,网页标题必须为斜体.当用户生成引用时,如何更改标题的字体样式并使其变为斜体?网页标题的字符串称为"TitleOfArticle".

感谢大家的帮助.

谢谢.


As you can see in my sample code I have strings for each combobox and they record the user''s input for each box. Then I combine all of them and put it into 1 string called "Citation" and when the user presses a button this string is displayed in a richtextbox. In a proper web citation for APA the title of the webpage needs to be Italic. How can I change the font style of the title and make it Italic when the user generates the citation? The string for the title of webpage is called "TitleOfArticle".

I appreciate everyones help.

Thanks.

推荐答案

您需要更改框的字体样式.
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/RichTextBoxFontbolditalic.htm [^ ]可能会有所帮助.

如何将文本框文本更改为粗体,斜体在C#Windows应用程序中 [
You need to change the box''s font style.
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/RichTextBoxFontbolditalic.htm[^] might help.

how to change a textbox text to bold,italic in C# windows application[^] is for a normal textbox, but might give you an idea as well.


嘿,Abhinav S,我发现了我一直在寻找的感谢您的帮助.我在"StackOverFlow"这里碰到过这篇文章的链接.您可以从名为"PsychoDad"的用户那里找到解决方案

http://stackoverflow.com/questions/956490/search-a-sentence- in-a-string-c [ ^ ]
Hey Abhinav S, I found what I was looking for thanks for your help. I came across this post on "StackOverFlow" heres the link. You can find the solution from the user called "PsychoDad"

http://stackoverflow.com/questions/956490/search-a-sentence-in-a-string-c[^]


这篇关于如何更改字符串的字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆