|
Use the web browser control comes with .net. Here is a sample code to give you some idea.
webBrowser1.Document.GetElementById("fieldname").SetAttribute("value", "foo");
webBrowser1.Document.GetElementById("button").InvokeMember("click");
|
|
|
|
|
Thank you for your replies. I will try that and update. I appreciate your time.
|
|
|
|
|
Thank you Abhisekh and Tamer.
Tamer, your solution worked like magic.
|
|
|
|
|
Hi, I'm currently stuck at my assignment where I need to create new buttons by naming it and also able to delete it after right clicking on it, choosing "delete" from the contextMenu
Here's my code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace New_One
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_MouseDown(object sender, MouseEventArgs e)
{
Point p = new Point(e.X, e.Y);
if (e.Button == MouseButtons.Right)
{
contextMenuStrip1.Show(button1, p);
}
}
private void toolStripMenuItem1_Click(object sender, EventArgs e)
{
button1.Dispose();
}
private void bt_add_Click(object sender, EventArgs e)
{
Button newButton = new Button();
newButton.Name = tb_name.Name;
newButton.Text = tb_name.Text;
flowLayoutPanel1.Controls.Add(newButton);
newButton.MouseDown += new MouseEventHandler(newButton_MouseDown);
}
void newButton_MouseDown(object sender, MouseEventArgs e)
{
Point p = new Point(e.X, e.Y);
if (e.Button == MouseButtons.Right)
{
}
}
}
}
|
|
|
|
|
jyjt_code wrote: Button newButton = new Button();
Tis button exists in your controls collection, but that's all. So, either create another collection that you can use to delete them from, or put tags on them so you can search your controls collection and find them.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Christian Graus wrote: So, either create another collection that you can use to delete them from, or put tags on them so you can search your controls collection and find them.
Erm, sorry to trouble you again. But i do i go about doing it?
|
|
|
|
|
Well, you do one of the two things I said
1 - create a member variable that is a list of controls, or buttons, depending on if buttons are the only control you create. Then you can find them in there and remove accordingly
2 - create a tag to identify your controls, and set the Tag property of Buttons you create. Then you can iterate over the built in controls collection and check the tags to see which are controls that you created.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello,
I am trying to make a browser using C# express, that will
support my web based game. I'm making it without a textbox.
I want about 10 buttons on the left side of the form, that
when clicked, tells the browser (located on the right side
of the form) which page to navigate to.
For instance:
[Gunsbutton] code: webBrowser1.Navigate(go to url http://www.mygame.com/guns.php);
[Armorbutton] code: webBrowser1.Navigate(go to url http://www.mygame.com/armor.php);
[Energybutton] code: webBrowser1.Navigate(go to url http://www.mygame.com/energy.php);
I'm just a beginner still, and I have looked everywhere
for what I think, should be a pretty simple code. But I
can't find it. Any help would be appreciated, I'm stuck.
|
|
|
|
|
You've pretty much got it...
webBrowser1.Navigate(new Uri("http://www.mygame.com/energy.php"));
EDIT: Oh, and if you're just using WinForms (As opposed to WPF), you don't even need the Uri... Just webBrowser1.Navigate("http://www.mygame.com/energy.php");
Or are you having trouble hooking the buttons up to the event? You should be able to just double-click each button in the designer, and Visual Studio will automatically create an event handler and show you where to start writing the code.
modified on Wednesday, September 30, 2009 3:33 PM
|
|
|
|
|
Thanks, it works with no errors.
I tried both of those but it wouldn't work before.
Must have been my ISP giving me troubles.
|
|
|
|
|
Hi
I am building a named pipe service using wcf using the example given in http://www.omegacoder.com/?p=101 but I am unable in Visual Studio 2008 to be able separately execute the windows form and then the console application.
Can someone explain to me how it is possible to start separately a number of projects in a solution in Visual Studio 2008? I have tried multi starts in Visual Studio, but this does not work.
Thanks
|
|
|
|
|
Two ways:
1) Start two different Visual Studios, and load a different project in each. This is easier if you have multiple monitors.
2) Start the first one normally, then in the Solution Explorer (Where it shows all of the projects and files in your solution), just right-click on the project name, pick Debug, Start New Instance.
|
|
|
|
|
Hi
I have both projects in the same project solution, and I have tried option two in your suggestion, but when I do so, Visual Studio hides solution explorer stopping me from starting the console project. How do you get round this?
Thanks
|
|
|
|
|
When you run your instance of your first application, press Ctrl + Alt + L this shortcut display Solution Explorer, now you able to see your other projects even first project, do the same as you do for first project.
Hope this work.
http://codeprojects.wordpress.com
|
|
|
|
|
Thanks, that was the answer!
|
|
|
|
|
Hi,
I have the weirdest problem.
I have a method in C# that call a function from a dll in MFC which preforms LoadLibrary() to another MFC dll.
When I'm calling this C# method from the main thread, everything is works great.
However, when I'm creating a thread (in c#) and calling the same function, the LoadLibrary in the second dll gets stuck, i.e. not returns.
And i tried also AfxLoadLibrary(), gets the same problem.
[DllImport("UpdateDB.dll")]
public static extern bool UpdateCommandsDB(String strDllPath, String strDBPath, ref string strError, bool bAppSideDB);
bRes = UpdateCommandsDB(m_sCommandDllPath, DBFilePath, ref sError, false);
extern "C" __declspec(dllexport) BOOL UpdateCommandsDB(LPCTSTR strDllPath,LPCTSTR strDBPath, CString &strError, bool bAppSideDB)
{
typedef bool(UPDATE_COMMANDS_DB_FUNC)(LPCTSTR, CString&, bool);
bool bRes;
AfxMessageBox(strDllPath);
AfxMessageBox(strDBPath);
HINSTANCE hDll = AfxLoadLibrary(strDllPath);
AfxMessageBox(hDll?_T("hDll OK"):_T("hDll NOK"));
UPDATE_COMMANDS_DB_FUNC *lpUpdateCommandsDB = (UPDATE_COMMANDS_DB_FUNC *)::GetProcAddress(hDll, "UpdateCommandsDB");
AfxMessageBox(lpUpdateCommandsDB?_T("lpUpdateCommandsDB OK"):_T("lpUpdateCommandsDB NOK"));
bRes = lpUpdateCommandsDB(strDBPath, strError, bAppSideDB);
AfxMessageBox(bRes?_T("bRes OK"):_T("bRes NOK"));
::AfxFreeLibrary(hDll);
return bRes;
}
Please Help
|
|
|
|
|
I have a problem regarding multiple log files. In my project i have a GeneralLog (singleton instance) that is configured from the app.config of the application.
<log4net>
<!-- The DebugFileAppender writes all messages to a log file-->
<appender name="GeneralAppender" type="log4net.Appender.FileAppender">
<!-->the file where to write the events<-->
<file value="GeneralLog.dat" />
<!-->the lowest level a message must reach in order to get written in the log file<-->
<threshold value="WARN" />
<!-->a value indicating that every message is appended to the log file<-->
<appendToFile value="true" />
<maximumFileSize value="100KB"/>
<rollingStyle value="Size"/>
<!-->the message layout<-->
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="[%d] - %m%n" />
</layout>
</appender>
<root>
<!-- add other appenders here and the log messages will be sent to every listed appender -->
<appender-ref ref="GeneralAppender" />
</root>
</log4net>
This works. During the execution I create alot more (dynamically) log files from appenders defined like this:
FileAppender generalLogAppender = new FileAppender();
generalLogAppender.Name = generalLogFileName;
generalLogAppender.File = "Log+"+ fileName + ".dat";
generalLogAppender.AppendToFile = true;
generalLogAppender.Threshold = Level.Warn;
PatternLayout layout2 = new PatternLayout();
layout2.ConversionPattern = "[%d] - %m%n";
layout2.ActivateOptions();
generalLogAppender.ActivateOptions();
BasicConfigurator.Configure(generalLogAppender);
The files are created, but nothing is written in them, only in the GeneralLog. I am really confused by this. I checked the net and of course CodeProject and found only static examples of logs, never a mixed case.
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
Solved.
BasicConfigurator.Configure(generalLogAppender);
had to be called after the appender was attached to the logger.
I am fighting against the Universe...
Reference-Rick Cook
|
|
|
|
|
Hello,
i add a Ado .net data entity(evpml), but i have an exception : The underlying provider failed on Open.
private static evpml GetEntities()
{
return new evpml();
}
public static List<users> GetUsersDC()
{
return GetEntities().users.ToList<users>();
}
Thank you verry mutch.
|
|
|
|
|
The exception looks like the database connection failed to connect to the database. I would start by verifying the connection string is correct.
|
|
|
|
|
yes, the connection is correct, i make this with the visual componement, i add the tables. please help me, thank you verry mutch.
|
|
|
|
|
Have you tried to debug and look at the exception an possibly inner exception?
only two letters away from being an asset
|
|
|
|
|
there are two ways out:
1. Modify the connection string to pass username/password credentials, instead of using a trusted connection.
2. Grant access to ‘NT AUTHORITY\NETWORK SERVICE’ to your database.
|
|
|
|
|
Dear All,
I have Adobe Reader Control in my Win Form. I am loading pdf files from Remote Server into this control.
Well, among Thousand of Files there are about 10 Files which can not be opened by Adobe Reader Control.
I am using Adobe Reader 8.0
For Test only, I copied those files from remote server to Drive C of my computer.
Then I made an application to show these PDF files.
Every thing worked correctly from my drive C.
let me mentioned that among thousands of files in remote server i can not only show these 10 files in adobe control other files are shown accurately.
Even I Tested WebBrowser Control to show these files from remote server but failure.
Let me make sure that file exists in remote sever. I am asking why these 10 files can not be shown from remote server? while i can browse these files using Adobe Reader 8.0 and the same i can browse them when i copy them to my c drive.
for sample code
string filePath=statee.ToString();
webVr.LoadFile(filePath);
webVr is the Adobe Control.
any ideas?
Abdul Rahaman Hamidy
Database Developer
Kabul, Afghanistan
|
|
|
|
|
Hello All..
i have a TreeView called "tvwProject" which in the frmLoad function i have the following code:
//tvwProject.SelectedNode = tvwProject.TopNode;
meaning that i don't want any node to be selected in the loading of the frm.
the event's flow continues to the Enter function & automatically to AfterSelect
in the Enter event -> tvwProject.SelectedNode == null
BUT in AfterSelect event -> tvwProject.SelectedNode = first node in treeView
how can i control the selected node ??
how can i see the event flow in my program ??
thank's
Eyal
|
|
|
|