Click here to Skip to main content
15,893,381 members
Home / Discussions / C#
   

C#

 
GeneralRe: Bind txt Box to database Pin
Manish7922-Sep-09 2:50
Manish7922-Sep-09 2:50 
GeneralRe: Bind txt Box to database Pin
Programm3r22-Sep-09 3:00
Programm3r22-Sep-09 3:00 
GeneralRe: Bind txt Box to database Pin
Manish7922-Sep-09 3:14
Manish7922-Sep-09 3:14 
GeneralRe: Bind txt Box to database Pin
Programm3r22-Sep-09 3:19
Programm3r22-Sep-09 3:19 
GeneralRe: Bind txt Box to database Pin
Keith Barrow22-Sep-09 3:16
professionalKeith Barrow22-Sep-09 3:16 
GeneralRe: Bind txt Box to database Pin
Manish7922-Sep-09 3:23
Manish7922-Sep-09 3:23 
GeneralRe: Bind txt Box to database Pin
Programm3r22-Sep-09 3:31
Programm3r22-Sep-09 3:31 
GeneralRe: Bind txt Box to database Pin
OriginalGriff22-Sep-09 3:32
mveOriginalGriff22-Sep-09 3:32 
GeneralRe: Bind txt Box to database Pin
Manish7922-Sep-09 3:46
Manish7922-Sep-09 3:46 
GeneralRe: Bind txt Box to database Pin
Keith Barrow22-Sep-09 3:50
professionalKeith Barrow22-Sep-09 3:50 
GeneralRe: Bind txt Box to database Pin
OriginalGriff22-Sep-09 3:56
mveOriginalGriff22-Sep-09 3:56 
AnswerRe: Bind txt Box to database Pin
Robert_Pan22-Sep-09 4:13
Robert_Pan22-Sep-09 4:13 
QuestionCustom progressbar doesn't update Pin
teknolog12322-Sep-09 1:56
teknolog12322-Sep-09 1:56 
QuestionRe: Custom progressbar doesn't update Pin
Programm3r22-Sep-09 3:21
Programm3r22-Sep-09 3:21 
AnswerRe: Custom progressbar doesn't update Pin
teknolog12322-Sep-09 4:02
teknolog12322-Sep-09 4:02 
GeneralRe: Custom progressbar doesn't update Pin
Programm3r22-Sep-09 21:21
Programm3r22-Sep-09 21:21 
GeneralRe: Custom progressbar doesn't update Pin
teknolog12323-Sep-09 9:26
teknolog12323-Sep-09 9:26 
QuestionBinary Serialization of Dictionary Pin
FJJCENTU22-Sep-09 1:28
FJJCENTU22-Sep-09 1:28 
AnswerRe: Binary Serialization of Dictionary Pin
Henry Minute22-Sep-09 1:44
Henry Minute22-Sep-09 1:44 
QuestionText over Progressbar - Question Pin
Programm3r22-Sep-09 1:25
Programm3r22-Sep-09 1:25 
Hi all,

I found the following code, that allows one to write a string on a ProgressBar ... Only thing is that I can't get it to work Confused | :confused: Confused | :confused: Can anyone else make it work, and if so ... what am I doing wrong?

// call the method
SetProgressBarText(progressBar1, null, ProgressBarTextLocation.Centered, Color.Black, SystemFonts.DefaultFont);

// Set the ProgressBar Text method
private void SetProgressBarText(System.Windows.Forms.ProgressBar Target,
    //The target progress bar
string Text,
    //The text to show in the progress bar
ProgressBarTextLocation Location,
    //Where the text is to be placed
System.Drawing.Color TextColor,
    //The color the text is to be drawn in
System.Drawing.Font TextFont
    //The font we use to draw the text
)
{
    //Make sure we didn't get a null progress bar
    if (Target == null)
        throw new ArgumentException("Null Target");

    //Now we can get to the real code
    //Check to see if we are to add in the percent
    if (string.IsNullOrEmpty(Text))
    {
        //We are to add in the percent meaning we got a null or empty Text
        //We give text a string value representing the percent
        int percent = (int)(((double)(Target.Value - Target.Minimum) / (double)(Target.Maximum - Target.Minimum)) * 100);
        Text = percent.ToString() + "%";
    }
    //Now we can add in the text
    //gr will be the graphics object we use to draw on Target
    using (Graphics gr = Target.CreateGraphics())
    {
        gr.DrawString(Text,
        TextFont,
            //The font we will draw it it (TextFont)
        new SolidBrush(TextColor),
            //The brush we will use to draw it
            //Where we will draw it
        new PointF(
            // X location (Center or Left)
        Location == ProgressBarTextLocation.Left ? 5 :
            //Left side
        progressBar1.Width / 2 - (gr.MeasureString(Text,
            //Centered
        TextFont).Width / 2.0F),
            // Y Location (This is the same regardless of Location)
        progressBar1.Height / 2 - (gr.MeasureString(Text,
        TextFont).Height / 2.0F)));
    }
}

public enum ProgressBarTextLocation
{
    Left,
    Centered
}


Many thanks in advance
Kind regards,


The only programmers that are better C# programmers, are those who look like this -> Green Alien | [Alien]



Java | [Coffee] Programm3r

My Blog: ^_^

AnswerRe: Text over Progressbar - Question Pin
Programm3r22-Sep-09 1:36
Programm3r22-Sep-09 1:36 
AnswerRe: Text over Progressbar - Question Pin
firda-cze18-Apr-10 22:21
firda-cze18-Apr-10 22:21 
GeneralRe: Text over Progressbar - Question Pin
Scott Sherin28-May-10 4:15
Scott Sherin28-May-10 4:15 
Questionhow to use a macro in c# Pin
Ajithevn22-Sep-09 0:58
Ajithevn22-Sep-09 0:58 
AnswerRe: how to use a macro in c# Pin
Programm3r22-Sep-09 1:39
Programm3r22-Sep-09 1:39 

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.