|
That format looks like a DataSet format. I would load it into a dataset. Then you can use the dataset to do what you need. You can get the DataView off of the dataTable and use the Rowfilter property to show only certain types if you need to do that.
Hope that helps.
Ben
|
|
|
|
|
First off, I am a Windows network technician with some coding back ground, mostly in C++ and VB, new to C#, so please bear with me.
I am trying to modify the following project by Douglas M. Weems (thanks a bunch Douglas for the code, it's been a GREAT help):
http://www.codeproject.com/cs/media/IECapture.asp[^]
We have a need to automate the process of capturing web sites of our clients as images. To do this I am modifying Douglas' project to do so. I have made most of the changes we require, but am stuck on one, hopefully last, issue.
I added a WebBrowser control, and modified the code to read the site loaded in it rather then from the first available web browser window open.
My problem is that when I automatically run the the button_click event which has the image capture code, the WebBrowser control does not load quickly enough, and the code calls properties of this control that are set to "null".
If I launch the app, and manually click the button which runs the capture code, it works without an issue, the image captures.
This is how I setup the automated process. On the Form Load event I read in a text file with the URL, and the WebBrowser control called axWebCap browses to this site. I then run the capture code in the Form Activated event.
I discovered that if I do this, that axWebCap.ReadyState = READYSTATE_LOADING. Now if I run this manually by running the ap and click the capture button the axWebCap.ReadyState = READYSTATE_COMPLETE.
I guess my question is, how can I run this code in a function after the Form has completely loaded, and therefore the axWebCap WebBrowser control has completely loaded as well, and it's properties are no longer set to null?
BTW, I am using Visual C# 2005 EE, and I would be more then happy to clarify anything I just posted.
Any help would be greatly appreciated!
Thanks,
Justin
|
|
|
|
|
Justin,
After you've assigned the URL to navigate to, you need to loop until the ReadyState is READYSTATE_COMPLETE; not actually assign it values.
Something like:
while (axWebCap.ReadyState != READYSTATE_COMPLETE)
{
// tells application to process messages ...
Application.DoEvents();
}
// when you come out of this loop, your page is now loaded and
// all the objects (DOM) etc... should exist
Hope that helps.
|
|
|
|
|
Thanks Douglas for your responce!
I actually have tried creating a while loop like this. I just can't figure out what to put for the "Application.DoEvents()" that will cause the WebBrowser control to fully load, or wait for it to fully load.
I tried the following:
string WebReady = axWebCap.ReadyState.ToString();<br />
<br />
while (WebReady != "READYSTATE_COMPLETE")<br />
{<br />
WebReady = axWebCap.ReadyState.ToString();<br />
}<br />
But that just causes an infinite loop. I am thinking that is because it is not refreshing the Ready Status. Do I need to refresh the form or something?
I thought about putting a timer in, but thought that could cause issues in the future if the page load fell outside the time limit.
Thanks again,
Justin
|
|
|
|
|
here's an example I just slapped together for testing ... grant it, my object names differ, but you'll get the idea ...
<br />
private void OnFormLoad(object sender, EventArgs e)<br />
{<br />
this.webBrowser1.Navigate(@"http://www.cnn.com");<br />
while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete)<br />
{<br />
Application.DoEvents();<br />
}<br />
MessageBox.Show("DONE loading!");<br />
<br />
}<br />
|
|
|
|
|
Thanks again Douglas!
I hear what you are saying, I just don't know what process to run that will refresh the WebBroswer.ReadyState until it is completed. What event or process can I keep running that will get me to WebBrowserReadyState.Complete before I run the capture code.
Here is some of the code:
private void frmMain_Load(object sender, EventArgs e)<br />
{<br />
Initialize_Site(null, null);<br />
<br />
string WebReady = axWebCap.ReadyState.ToString();<br />
<br />
while (WebReady != "READYSTATE_COMPLETE")<br />
{<br />
WebReady = axWebCap.ReadyState.ToString();<br />
}<br />
<br />
}<br />
<br />
private void frmMain_Activated(object sender, System.EventArgs e)<br />
{<br />
button1_Click(null, null);
}<br />
<br />
private void Initialize_Site(object sender, EventArgs e)<br />
{<br />
TextReader WebConfig = new StreamReader(@"c:\\IECapture\config.txt");<br />
<br />
int LineCount = 4;<br />
string[] ConfigLines = new string[LineCount];<br />
<br />
for (int i = 1; i < LineCount; i++)<br />
{<br />
ConfigLines[i] = WebConfig.ReadLine();<br />
}<br />
<br />
string Address = ConfigLines[1];<br />
axWebCap.Navigate(Address);<br />
<br />
}
Thanks,
Justin
|
|
|
|
|
You need only add a call to Application.DoEvents(); That will tell your application to pump messages and whatnot while you wait for the ReadyState to change ... so in your code, you would
private void frmMain_Load(object sender, EventArgs e)
{
Initialize_Site(null, null);
string WebReady = axWebCap.ReadyState.ToString();
while (WebReady != "READYSTATE_COMPLETE")
{
// tell application to process pending events
Application.DoEvents();
// get the readystate
WebReady = axWebCap.ReadyState.ToString();
}
//add your capture code here ...
}
-- modified at 16:19 Tuesday 3rd April, 2007
|
|
|
|
|
I think I understand now. Pardon my slowness.
So the line:
Application.DoEvents();
That is an actual event, huh? This shows my lack of knowledge in programming. I have though when people posted this it meant to run a custome function. I will try this
What does the Application.DoEvent() actually do?
Thanks a bunch for your help!
|
|
|
|
|
Well, without it ... your while loop is just going to 'hang' there, and take all the processing until it's condition is met. This is obviously not what you want to have happen ...
You want to your program to 'wait' until the ReadyState is complete. By calling DoEvents, that allows your application to process messages that are sitting in the message queue (essentially, it lets your program 'run' while you wait for that state change to occur).
Hope that helps.
|
|
|
|
|
I just did what you said and it worked like a charge. Added Application.DoEvents() to my while loop, and it works flawlessly.
Thank you SO very much Douglas. It is greatly appreciated, and thanks for putting up with a coding newb!
|
|
|
|
|
no problem. glad I could help.
|
|
|
|
|
|
Diego F. wrote: Is there any way to solve that?
Yes, make sure the icon is in the imagelist of the listview and set the imageindex for the item to it.
led mike
|
|
|
|
|
I can't solve the problem.
When I open a file in the listview1 I do that (is vb code here)
Dim files As String() = Directory.GetFiles(sourceDir)
For Each file As String In files
ImageList1.Images.Add(System.Drawing.Image.FromFile(file))
Next
I added then something like listview1.LargeImageList = ImageList1
But when using drag & drop in the second listview, the images doesn't appear. Should I load the ImageList1 in the second listview? I thought that the item contains the image and when I drop in the other listview, moves it all.
Regards,
Diego F.
|
|
|
|
|
Hallo. I'm writing AddIn for Excel 2007 in C#, using VSTO 2005 SE. I'd like to have possibility to use something similar to templates - specially saved Excel objects (for example: a pattern of the table) for further use.
For example: I'll create an Excel table which represents information about person (Name, Surname etc.) and I'd like to paste this table in a Worksheet, allow user to fill it and then commit data to Database.
How can I do this without writing any code which will creates this table at runtime.
|
|
|
|
|
You should really post this question in the VSTO[^] forum.
If you were using VSTO, you could create an Excel document-level template and use that to gather up your data ...
As for dynamically creating a table and whatnot, I'm sure that someone in the VSTO group will be able to help guide you.
|
|
|
|
|
Thanks, Douglas, for your advice.
|
|
|
|
|
Hello,
My app dependes on a sql database I want my setup project to attach the sql files to the framework or any thing else to run the database like the MSDE 2000 How can I do this?
Thanks.
Dad
|
|
|
|
|
This question is far to vague. What database are you using (SQL Server, Firebird, MySQL)? What version of the .NET Framework?
You have to supply more detailed information.
|
|
|
|
|
I am esigning a usercontrol with a panel child. Using a ControlDesigner I used EnableDesignMode to make it possible to drop controls in the panel at design time. Now i wanted to lock te panel because you can move and resize the panel inside the usercontrol. I made another ControlDesigner class to use on the panel class and override the SelectionRules to set it to locked. If I use this locked thing, the functionality of dropping controls in the panel dissapears. Howe can I implement these two things without problems?
My code:
<br />
[DesignerAttribute( typeof( AdvancedNoteDesigner ) )]<br />
public partial class AdvancedNote : UserControl<br />
{<br />
...<br />
}<br />
<br />
public class AdvancedNoteContentPanel : Panel<br />
{<br />
public AdvancedNoteContentPanel()<br />
{<br />
this.SetStyle( ControlStyles.AllPaintingInWmPaint , true );<br />
this.SetStyle( ControlStyles.OptimizedDoubleBuffer , true );<br />
this.SetStyle( ControlStyles.ResizeRedraw , true );<br />
this.SetStyle( ControlStyles.SupportsTransparentBackColor , true );<br />
this.SetStyle( ControlStyles.UserPaint , true );<br />
<br />
this.BackColor = Color.Transparent;<br />
}<br />
}<br />
<br />
internal class AdvancedNoteDesigner : ControlDesigner<br />
{<br />
public override void Initialize( IComponent component )<br />
{<br />
base.Initialize( component );<br />
<br />
AdvancedNote advancednote = (AdvancedNote)component;<br />
<br />
EnableDesignMode( advancednote.ContentPanelFront , "ContentPanelFront" );<br />
EnableDesignMode( advancednote.ContentPanelBack , "ContentPanelBack" );<br />
}<br />
}<br />
<br />
internal class AdvancedNoteContentPanelDesigner : ControlDesigner<br />
{<br />
public override SelectionRules SelectionRules<br />
{<br />
get<br />
{<br />
SelectionRules selRules = base.SelectionRules;<br />
<br />
selRules = SelectionRules.Locked;<br />
<br />
return selRules;<br />
}<br />
}<br />
}<br />
<br />
|
|
|
|
|
i have used System.Diagnostics.Process.Start("explorer.exe", "/e,/select,c:");
for Opening My Computer. it works. but i want to open My Doc, My Network place also. how it possible?
Thanks.
Sanjit.rajbanshi@wlinktech.com
|
|
|
|
|
You should just be able to put "My Documents" in the arguments list and it should work fine.
So the code is:
System.Diagnostics.Process.Start("explorer.exe", "My Documents");
Hope that helps.
Ben
|
|
|
|
|
You can use the following to get that path:
<br />
string myComputerFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);<br />
You can then use that information to shell to it ...
|
|
|
|
|
hi
i want to run exe file(s) in buffer,How to do ..thanks(pe,injection,...)
Description :
my exe is Encrypted and exist in CD-drive and when user start my program, it check information of that computer and cd ... then Decrypt that exe in ram and run it from ram (on the fly),without extract on disc. but ho to do ?
|
|
|
|
|
ALL executables that you write run in RAM. You don't need to run from a disk because you can use AutoRun (assuming that it is enabled) to run the application from the CD. If you're looking to see how you can inject a virus/worm onto the client machine then you've come to the wrong place.
Deja View - the feeling that you've seen this post before.
|
|
|
|