Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:04:02+00:00 2026-06-12T19:04:02+00:00

I have this button click code wich is working now: private void button6_Click(object sender,

  • 0

I have this button click code wich is working now:

private void button6_Click(object sender, EventArgs e)
        {

            using (var w = new StreamWriter(keywords))
            {
                crawlLocaly1 = new CrawlLocaly();
                crawlLocaly1.StartPosition = FormStartPosition.CenterParent;
                DialogResult dr = crawlLocaly1.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    if (LocalyKeyWords.ContainsKey(mainUrl))
                    {
                        LocalyKeyWords[mainUrl].Clear();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    else
                    {
                        LocalyKeyWords[mainUrl] = new List<string>();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    Write(w);
                    listBox1.Items.Add("Url: " + LocalyKeyWords[mainUrl] + " --- " + "Localy KeyWord: " + crawlLocaly1.getText());
                }
                if (dr == DialogResult.Cancel)
                {
                    Write(w);
                }
            } 
        }

I need that when i make a change either to the mainUrl(key) or to the crawlLocaly1.getText()(the value of the key) so it iwll change in real time also in the ListBox. I tried to do it like this:

listBox1.Items.Add("Url: " + LocalyKeyWords[mainUrl] + " --- " + "Localy KeyWord: " + crawlLocaly1.getText());

But its not showing the key and its vlaue and its adding a new line instead of updating only the value of the key if the key already exist or if the key is not exist in the List to add to the ListBox the new key and its value.

How do i make it so it will update it in real time in the ListBox ?


Ok changed the ListBox line to:

listBox1.Items.Add("Url: " + mainUrl + " --- " + "Localy KeyWord: " + crawlLocaly1.getText());

Now its adding it good but its adding it as a new line. I want that it will add it and replace the line that already the mainUrl exist in the ListBox.

And if the mainUrl is not exist in the ListBox then add it with its value in a new line.
But all the time if the Key(mainUrl) exist in the ListBox replace it or change only the value(crawlLocaly1.getText() ) .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:04:03+00:00Added an answer on June 12, 2026 at 7:04 pm

    To correct the line
    when you write LocalyKeyWords[mainUrl] you get a List<string> object. So when you concat this List to string, you actually call to the method List<string>.ToString().

    Try to use this line insted:

    listBox1.Items.Add("Url: " + mainUrl + " --- " + "Localy KeyWord: " + LocalyKeyWords[mainUrl][0]); 
    

    For the real time problem
    To edit the line in real time you need to remove the previous line before, like that

    private void button6_Click(object sender, EventArgs e) 
            { 
    
                using (var w = new StreamWriter(keywords)) 
                { 
                    crawlLocaly1 = new CrawlLocaly(); 
                    crawlLocaly1.StartPosition = FormStartPosition.CenterParent; 
                    DialogResult dr = crawlLocaly1.ShowDialog(this); 
                    if (dr == DialogResult.OK) 
                    { 
                        int line = listBox1.Items.Count;
                        if (LocalyKeyWords.ContainsKey(mainUrl)) 
                        { 
                            line = listBox1.Items.IndexOf("Url: " + mainUrl+ " --- " + "Localy KeyWord: " + LocalyKeyWords[mainUrl][0]);
    
                            listBox1.Items.Remove("Url: " + mainUrl+ " --- " + "Localy KeyWord: " + LocalyKeyWords[mainUrl][0]);
                            LocalyKeyWords[mainUrl].Clear(); 
                            LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText()); 
                        } 
                        else 
                        { 
                            LocalyKeyWords[mainUrl] = new List<string>(); 
                            LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText()); 
                        } 
                        Write(w); 
                        listBox1.Items.Insert(line, "Url: " + mainUrl+ " --- " + "Localy KeyWord: " + LocalyKeyWords[mainUrl][0]);
                    } 
                    if (dr == DialogResult.Cancel) 
                    { 
                        Write(w); 
                    } 
                }  
            } 
    

    Just for you know, to work with data that contains a two or more variables. Its better to use the ListView control. This control know how to work like list, and it can split the data to columns.
    See ListView in msdn.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this button with the code: private void button22_Click_1(object sender, EventArgs e) {
I have this code: 001 private void uiButton1_Click(object sender, EventArgs e) 002 { 003
I have this on a button: private void Button_Click(object sender, RoutedEventArgs e) { string
I have this code protected void btnPrasaj_Click(object sender, EventArgs e) { List<ListItem> lista =
I have this code first the constructor and button click event: using System.Text; using
i have this code in the button click to show selection image when the
I have this code in the end of link button click: Response.ContentType = application/zip;
I have this setup: <div class=fadetoggle> <div>Content</div> <div>Content</div> </div> And this code: $(.button).click(function ()
Say I have this mockup-code: button.click(function(){generateForm();} function generateForm(){ div.append(<input type='text' id='x'>); } I will
I have this click button code \$(#extractmonkeys).click(function () { \$(#grapharea).html( ); \$(#paramselection).html( ); How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.