Can i change winform tool 's property using c#???

Recommended Answers

All 12 Replies

Yes but you'll need to clarify your question for us if you need help doing so.

What tool is it?
What property is it?
What code have you got so far?

i am using "WebBrowser" in winform and now i want to change value of property named "url", can i?

Yeah just like anyother property I would assume you can use it just like the properties of anyother control.

Just do:

myWebBrowser.Url."The Rest Goes Here" = "What ever you want it too"

Have a look at this link it should help you with everything you need to know about the methods and properties for the WebBrowser control.

i understand all you say but i have little problem, now see
"What ever you want it too" here i have to place the value for "URL" property
and
"The Rest Goes Here" here what i have to place ????

Have a look at this instead I think original reply was way off, my apologies.

still i can not understand
please take a look on my program

            private void button4_Click(object sender, EventArgs e)
            {
                webBrowser1.Url.Equals("http//www.yahoo.com");
                webBrowser1.Refresh();
            }

now please what i have to do

Using webBrowser1.Url.Equals is simply comparing the current value of the Url with http//www.yahoo.com to see if they are the same. this would be good if you wanted to use it as a condition in an if statement but isn't used for setting it's value.

According to the link I sent you earlier you have to do something like the following:

// Pass in the website Url
public void MyMethod(string address)
{
    if (!address.StartsWith("http://"))
    {
        address = "http://" + address;
    }

    try
    {
        webBrowser1.Navigate(new Uri(address));
    }
    catch (System.UriFormatException)
    {
        // put messageBox here if required
    }
}

Once you've done the above you can then get the current Url from the webBrowser by accessing the Url property (which will help solve one of your other threads on here).

Hope this helps.

commented: very much cooperative +0

thanks for your response, but i think still you do not understand that what i want
now see,
i have to three controls:
1. textBox
2. button
3. webBrowser
now the thing which i want:
i want to enter to the url in the textBox then i have to click on button, as i clicked the button the webBrowser will open that url which i placed in textBox
Now tell what should have i to do????

Do you know how to retreive a value from a textBox or call a method?

You really need to read these two threads that are posted at the top of the C# form

New Programmers - What resources are available to…

Getting Started With C# - The List

How ever for now add a textBox and a button to you form. Next double click the button so that it adds the button_Clicked method in for you and add MyMethod(textBox.Text1); inside the curly braces of the button_Clicked method. Next copy and paste the method I gave you in one of my earlier.

Unfortunatly the DaniWeb rules state that you have to show what you've done before I can help you so next time you will have to show that you have attempted to solve the problem yourself before anyone, especially myself, will help you.

I hope this helps and Google C#.Net programming for beginners. I'd rather help you acheive something through guidence than doing it for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.