Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
C#
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();
        }
    }
}

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.
Posted
v2

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.
 
Share this answer
 
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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900