Click here to Skip to main content
15,895,829 members
Home / Discussions / C#
   

C#

 
GeneralRe: Passing strings between windows forms Pin
OriginalGriff2-Mar-10 4:34
mveOriginalGriff2-Mar-10 4:34 
AnswerRe: Passing strings between windows forms Pin
DX Roster4-Mar-10 18:38
DX Roster4-Mar-10 18:38 
QuestionExporting DataGridView to excel Pin
Hum Dum1-Mar-10 23:18
Hum Dum1-Mar-10 23:18 
AnswerRe: Exporting DataGridView to excel Pin
Rashmi_Karnam2-Mar-10 0:13
Rashmi_Karnam2-Mar-10 0:13 
AnswerRe: Exporting DataGridView to excel Pin
Dan Mos2-Mar-10 1:30
Dan Mos2-Mar-10 1:30 
GeneralRe: Exporting DataGridView to excel Pin
Hum Dum2-Mar-10 2:04
Hum Dum2-Mar-10 2:04 
GeneralRe: Exporting DataGridView to excel [modified] Pin
Dan Mos2-Mar-10 2:17
Dan Mos2-Mar-10 2:17 
QuestionControl Authoring OnPaint not working as expected Pin
TheFoZ1-Mar-10 22:54
TheFoZ1-Mar-10 22:54 
Hi All

I'm trying to author a control which displays text vertically. I've overridden the OnPaint method and Text property so that if the Text is Changed it calls the new OnPaint method. When the text is changed, the old text does not disappear and the new text is overlaid on the old. How do I stop this from happening?

The OnPaint method looks like this
protected override void OnPaint(PaintEventArgs pe)
{
    base.OnPaint(pe);

    if (!String.IsNullOrEmpty(Text))
    {
        System.Drawing.Graphics formGraphics = pe.Graphics;

        System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 10);
        System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
        float x = 150f;
        float y = 50f;
        System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(StringFormatFlags.DirectionVertical);
        formGraphics.DrawString(Text, drawFont, drawBrush, x, y, drawFormat);
        drawFont.Dispose();
        drawBrush.Dispose();
        formGraphics.Dispose();
    }

}

And the Text property is
public override string Text
{

    get { return base.Text; }
    set
    {
        base.Text = value;
        this.OnPaint(CreateNewPaintEventArgs());
    }

}

private PaintEventArgs CreateNewPaintEventArgs()
{
    return new PaintEventArgs(CreateGraphics(), new Rectangle(new Point(0, 0), Size));
}


Your help is appreciated.
The FoZ

AnswerRe: Control Authoring OnPaint not working as expected Pin
OriginalGriff1-Mar-10 23:54
mveOriginalGriff1-Mar-10 23:54 
GeneralRe: Control Authoring OnPaint not working as expected Pin
TheFoZ1-Mar-10 23:56
TheFoZ1-Mar-10 23:56 
QuestionC# - Fill a .xlsx / .xls - file with data based on a grid Pin
Mschauder1-Mar-10 22:44
Mschauder1-Mar-10 22:44 
AnswerRe: C# - Fill a .xlsx / .xls - file with data based on a grid Pin
TheFoZ1-Mar-10 23:54
TheFoZ1-Mar-10 23:54 
AnswerRe: C# - Fill a .xlsx / .xls - file with data based on a grid Pin
Rashmi_Karnam2-Mar-10 0:17
Rashmi_Karnam2-Mar-10 0:17 
AnswerRe: C# - Fill a .xlsx / .xls - file with data based on a grid Pin
Dan Mos2-Mar-10 1:32
Dan Mos2-Mar-10 1:32 
QuestionConverting to Hex Pin
Deepak.Prahlad1-Mar-10 22:28
Deepak.Prahlad1-Mar-10 22:28 
AnswerRe: Converting to Hex Pin
Luc Pattyn1-Mar-10 22:47
sitebuilderLuc Pattyn1-Mar-10 22:47 
GeneralRe: Converting to Hex Pin
Deepak.Prahlad1-Mar-10 23:03
Deepak.Prahlad1-Mar-10 23:03 
GeneralRe: Converting to Hex Pin
Luc Pattyn1-Mar-10 23:14
sitebuilderLuc Pattyn1-Mar-10 23:14 
Questionproblem in debugging the windows application Pin
Amit Spadez1-Mar-10 22:22
professionalAmit Spadez1-Mar-10 22:22 
AnswerRe: problem in debugging the windows application Pin
Luc Pattyn1-Mar-10 22:49
sitebuilderLuc Pattyn1-Mar-10 22:49 
GeneralRe: problem in debugging the windows application Pin
Amit Spadez1-Mar-10 22:57
professionalAmit Spadez1-Mar-10 22:57 
AnswerRe: problem in debugging the windows application Pin
Tony Richards1-Mar-10 22:52
Tony Richards1-Mar-10 22:52 
QuestionConvert string to UTF-8 Pin
dabuskol1-Mar-10 20:41
dabuskol1-Mar-10 20:41 
AnswerRe: Convert string to UTF-8 Pin
sanforjackass1-Mar-10 21:29
sanforjackass1-Mar-10 21:29 
GeneralRe: Convert string to UTF-8 Pin
Rajesh Anuhya1-Mar-10 21:53
professionalRajesh Anuhya1-Mar-10 21:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.