Click here to Skip to main content
15,905,874 members
Home / Discussions / C#
   

C#

 
AnswerRe: Searching files Pin
Eddy Vluggen10-May-09 21:39
professionalEddy Vluggen10-May-09 21:39 
GeneralRe: Searching files Pin
Rajdeep.NET is BACK10-May-09 21:51
Rajdeep.NET is BACK10-May-09 21:51 
GeneralRe: Searching files Pin
Eddy Vluggen10-May-09 22:18
professionalEddy Vluggen10-May-09 22:18 
GeneralRe: Searching files Pin
Rajdeep.NET is BACK10-May-09 22:46
Rajdeep.NET is BACK10-May-09 22:46 
GeneralRe: Searching files Pin
Eddy Vluggen10-May-09 22:52
professionalEddy Vluggen10-May-09 22:52 
GeneralRe: Searching files Pin
Rajdeep.NET is BACK10-May-09 23:17
Rajdeep.NET is BACK10-May-09 23:17 
AnswerRe: Searching files Pin
Vikram A Punathambekar10-May-09 22:26
Vikram A Punathambekar10-May-09 22:26 
GeneralRe: Searching files Pin
Rajdeep.NET is BACK10-May-09 22:41
Rajdeep.NET is BACK10-May-09 22:41 
GeneralRe: Searching files Pin
Vikram A Punathambekar11-May-09 2:19
Vikram A Punathambekar11-May-09 2:19 
GeneralRe: Searching files Pin
Rama Krishna Vavilala29-May-09 9:49
Rama Krishna Vavilala29-May-09 9:49 
QuestionMy windows server trace is showing error Pin
avi_dadi200210-May-09 20:58
avi_dadi200210-May-09 20:58 
QuestionC# NETWORKING PROBLEM Pin
teddy110-May-09 20:46
teddy110-May-09 20:46 
AnswerRe: C# NETWORKING PROBLEM Pin
Dave Kreskowiak11-May-09 5:01
mveDave Kreskowiak11-May-09 5:01 
AnswerRe: C# NETWORKING PROBLEM Pin
Larryville12-May-09 4:09
Larryville12-May-09 4:09 
QuestionSeperate one string into 2 Pin
KIDYA10-May-09 20:45
KIDYA10-May-09 20:45 
AnswerRe: Seperate one string into 2 Pin
Anubhava Dimri10-May-09 21:06
Anubhava Dimri10-May-09 21:06 
GeneralRe: Seperate one string into 2 Pin
KIDYA10-May-09 21:25
KIDYA10-May-09 21:25 
GeneralRe: Seperate one string into 2 Pin
Anubhava Dimri10-May-09 21:40
Anubhava Dimri10-May-09 21:40 
AnswerRe: Seperate one string into 2 Pin
OriginalGriff10-May-09 21:46
mveOriginalGriff10-May-09 21:46 
GeneralRe: Seperate one string into 2 Pin
KIDYA10-May-09 23:05
KIDYA10-May-09 23:05 
QuestionProgress Bar Pin
S K Y10-May-09 16:02
S K Y10-May-09 16:02 
AnswerRe: Progress Bar Pin
N a v a n e e t h10-May-09 16:25
N a v a n e e t h10-May-09 16:25 
GeneralRe: Progress Bar Pin
S K Y10-May-09 16:39
S K Y10-May-09 16:39 
GeneralRe: Progress Bar Pin
N a v a n e e t h10-May-09 17:21
N a v a n e e t h10-May-09 17:21 
S K Y wrote:
i couldn't get progress bar like message box..


What do you mean by progress bar like message box? A modal progress bar which will not allow to click on other forms when progress is shown? If yes, here is a method

1 - Create a new form say Progress
2 - Add a progress bar say "pb" to this form.
3 - Create a delegate in this form which will call back the method to execute from the progress window. Refer the following code
// use this class to interact with progress form your form
public class ProgressEventArgs
{
    ProgressBar pb;
    Form form;

    public ProgressEventArgs(ProgressBar pb, Form form)
    {
        this.pb = pb;
        this.form = form;
    }

    public void PerformProgress(int value)
    {
        form.BeginInvoke((MethodInvoker)delegate
        {
            this.pb.Value = value;
        });
    }

    public void StopProgress()
    {
        form.BeginInvoke((MethodInvoker)delegate
        {
            form.Close();
        });
    }
}

public delegate void WorkStartedHandler(ProgressEventArgs pe);

// your progress form
public partial class Progress : Form
{
    WorkStartedHandler method;
    public Progress()
    {
        InitializeComponent();
    }

    public void ShowProgress(int minimum, int maximum, WorkStartedHandler method)
    {
        pb.Minimum = minimum;
        pb.Maximum = maximum;
        this.method = method;
        new Thread(DoWork).Start();
        this.ShowDialog();
    }

    void DoWork()
    {
        method(new ProgressEventArgs(this.pb, this));
    }
}
The above code is simple and self explaining. You can use this like
private void import(object sender, EventArgs e)
{
    if (listView1.Items.Count == 0)
    {
         Progress p = new Progress();
         p.ShowProgress(1, dlg.FileNames.Length, DoWork);
    }
}

void DoWork(ProgressEventArgs pe)
{
    int i = 0;
    foreach (string path in dlg.FileNames)
    {
        .............
        .............
        ++i;
        pe.PerformProgress(i);
    }
    pe.StopProgress();
}
I wrote the above code in CP editor directly, so expect some compile time errors.

Smile | :)


QuestionRead Sql Server Message from C# Pin
I Believe In GOD10-May-09 13:53
I Believe In GOD10-May-09 13: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.