Hi..
I am working on richtextbox now I want to chang font style at run time by using shortcut key like ctrl+b..
How it is possible..?
any body help please
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
FroglegRank #1,020 · 1.9K reputationPosted May 11, 2011, 10:44 PM EDT
public partial class Form1 : Form
{
Font myFont = new Font("Arial", 16,FontStyle.Italic);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers== Keys.Control && e.KeyCode== Keys.B)
{
richTextBox1.SelectionFont = myFont;
}
}
}
Kanhialal kkRank #8,477 · 221 reputationPosted May 11, 2011, 10:57 PM EDT
Working properly as required.
but now I want to save in database as some portion is bold and some regular format..
kindly help.
FroglegRank #1,020 · 1.9K reputationPosted May 11, 2011, 11:33 PM EDT
public partial class Form1 : Form
{
Font myFont = new Font("Arial", 16,FontStyle.Italic);
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.KeyPreview = true;
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.Modifiers== Keys.Control && e.KeyCode== Keys.B)
{
richTextBox1.SelectionFont = myFont;
}
}
private void bttnLoad_Click(object sender, EventArgs e)
{
richTextBox1.LoadFile("test.rtf");
}
private void bttnSaveToFile_Click(object sender, EventArgs e)
{
richTextBox1.SaveFile("test.rtf");
}
private void bttnSaveToDatabase_Click(object sender, EventArgs e)
{
string rtfStr = this.richTextBox1.Rtf;//text only
//save to database
}
Kanhialal kkRank #8,477 · 221 reputationPosted May 12, 2011, 2:29 AM EDT
sir I have retrieved items in comboxbox from database like this...
SELECT UPPER(item_Name) as Item_Name FROM New_Item_ForShop order by Item_Name asc
now I want to select the data as Alphabetically I mean if I press G in keyboard than select the series of G in combox..
thanks for helping almost...
Kindly further help