|
VS 2005 C# Express, .NET 2.0
The following code causes the Body member of the Webbrowser control to be set to null. Why?
mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2) this.webBrowser1.Document.DomDocument;
doc2.designMode = "On";
I am trying to programmatically select an element (<OPTION>) in a web page listbox (<SELECT>) the way a user would with the left mouse button. So, far I've found nothing that will do this.
|
|
|
|
|
cweeks78681 wrote: I am trying to programmatically select an element (OPTION) in a web page listbox (SELECT) the way a user would with the left mouse button.
What does that have to do with setting designMode to ON?
Would you know how to do that in a javascript running in the HTML page? If not you should learn how to do that first because it is the same thing. The DOM in WebBrowser is the same DHTML DOM you use in javascript.
You want to get a reference to the DHTML listbox element and set it's .selectedIndex property to the desired index.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
> What does that have to do with setting designMode to ON?
It was a shot in the dark. I thought maybe the HTMLDocument was in some kind of read-only state because I have NEVER found a way to modify a page in the web browser. Some kind of exception is always thrown. One said something about an access violation.
|
|
|
|
|
That's what I call it, anyway...
I want to write a class that would know how to act on two different cases:
- A single object of it was created.
- An array of objects of it was created.
The purpose of this is to fire a different event for each of the cases.
Lets take WinSck for example...
If you create a single object, you get the regular arguments.
But create an array, and it automatically generates the same event with an additional index argument.
1. How can I detect from within my class if it's used as an array?
2. How can I, after detection, pass the index of the object, without holding an index/id field inside the class?
Thanks in advance,
Shy.
|
|
|
|
|
Hu?
I don't think you made yourself clear enough to get helpful answers.
When you want to know how many instances of your class have been created, you can increase a static counter in the c'tor of your class, for example.
But your class will never know if it's part of an Array or not, unless you define a separate Collection class to hold elements of your class.
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
1. You can't. How the reference to an object is stored is not known to the object.
What you can do is to use a static variable in the class that keeps track on how many objects has been created.
2. You can't. Same reason.
---
b { font-weight: normal; }
|
|
|
|
|
Thank you both for you comments...
I've got an idea, but not sure if it's possible.
I can create two different classes that will inherit thier common stuff.
Each of this classes would call the appropriate event (With/out index).
One of them will use a static field as you both mentioned.
BUT... Question is...
Can I force one class to be used as an array, and not as a single object?
Maybe inheriting both System.Array, and my base class would help?
Thanks,
Shy
Added:
Or maybe I can just implement ICollection...?
-- modified at 11:29 Saturday 6th May, 2006
|
|
|
|
|
I have a custom collection class that is bound to a PropertyGrid object, which functions very well. Part of the collection class is as follows:
public DotCommand[] Attributes
{
get
{
return attributes;
}
set
{
attributes = value;
if (AttributesChanged != null)
AttributesChanged(this, new EventArgs());
}
}
The PropertyGrid shows the Attributes item, with an ellipsis button (...); when I click on the button the Object Collection Editor appears and I can add items (the DotCommand object is very simple, it just contains two string objects, exposed with public get/set properties). When I dismiss the Object Collection Editor with Ok, the setter for the Attributes property above is not hit. If I press the ellipsis again, only the last added item is displayed (the others are gone).
What do I need to do to wire the PropertyGrid and Attributes property together properly? Is it because the Attributes property is an array (DotCommand[] )?
- Dy
|
|
|
|
|
-Dy wrote: When I dismiss the Object Collection Editor with Ok, the setter for the Attributes property above is not hit.
This is the correct behavior. The Object Collection Editor is not allowing the user to choose which array the property should be set to, but, rather, is allowing the user to modify the contents of the array. The objects in the array are being edited.
-Dy wrote: If I press the ellipsis again, only the last added item is displayed (the others are gone).
This might be due to the fact that the property is an array type. If you were to use an ArrayList instead of an array, does that fix the problem? I imagine it would.
Josh
|
|
|
|
|
I the days of COM we had reference counting, which i beleive probably still exists within .Net in some form or other otherwise the gargabe collector wouldn't be able to do it's job.
I basically want to code a simple but semi intelligent cache, where upon an object being added to the cache it remains there whilst there's more than one reference to it. One of the references being the cach of course. But when only the cache has a reference and maintains that single reference for around say 5 mins, after 5 mins it unloads it. I'd like the cache to manage this without the business object having to know anything about the cache, otherwise I could probably place a call within the business objects dispose() to decrement a reference count of some form.
The reason for this is to create a smart datalayer and reduce the number of trips to the database for certain business objects.
Or is there another way????
Andy
|
|
|
|
|
|
Hi all I am doing a project in C# in which I need to get html,doc,and txt files from the selected directory and leaving the remaining files. now stringpattern argument of GetFiles method only allows us to get one or all type of documents in the directory plz tell me how can i get three types of documents
Regards,
|
|
|
|
|
It's simple !
Call "GetFiles" for each file type.
<br />
string folder = "c:\\";<br />
ArrayList list = new ArrayList();<br />
list.AddRange(Directory.GetFiles(folder, "*.html"));<br />
list.AddRange(Directory.GetFiles(folder, "*.doc"));<br />
list.AddRange(Directory.GetFiles(folder, "*.txt"));<br />
string[] files = (string[])list.ToArray(typeof(string));<br />
Best regards, Alexey.
|
|
|
|
|
thxx brother but i want a technique through which i get all of these documents in one pass. coz if now i tried this i have to change the whole design of my project which is not possible so is there any other way out ??
-- modified at 5:04 Monday 8th May, 2006
|
|
|
|
|
Rizwan Rathore wrote: i want a technique through which i get all of these documents in one pass.
Wrap it in a method...
|
|
|
|
|
hi all
codeproject is best
i want connect to access db programmatically but .. i will not successfull .. finally i done this operation and i found my problem . that is Dataset object that when i create dataset programmatically ,
i can't connect to db, and when i drog and drop dataset object in design time and specify parameters (like columns,type of it's,...) my program connect to database . how to solve my problem that i create dataset programmatically and my program connect to db ???
please give me a full example with source and db hase password ...
thanks..
codeproject is best ..
|
|
|
|
|
Creating a DataSet at runtime or at "design time" (which really just means that VS writes the code for you - it's still created at runtime) has absolutely no relevance as to whether an application can connect to a database. My guess is that whatever you're doing at design-time is causing your db connection information to be generated as well. If you want a
hdv212 wrote: full example with source and db hase password
then just check out the code that Visual Studio writes for you after you drag and drop a DataSet onto the Form.
Please, don't ever ask for a full source code example. We have our own jobs.
Josh
|
|
|
|
|
i need a program which can give information like
CPU type,cpu utilization, maximum application address, minimum application address, available page file,available physical memory, available virtual memory, size of structur, memory in use,total page size, total physical memory.
|
|
|
|
|
Go this url and find your api :
http://www.pinvoke.net
|
|
|
|
|
In the TAPI3_0 Application Development with C# sample posted here there is an error "compobj.dll is too old for the ole2.dll initialized " when i am trying to call through the modem(Voice Modem).
Are there any solutions for this?
|
|
|
|
|
hi friends,
I have few queries in C#:
1)how to call javascript function from c# function
2)how to pass string arrays from c# function to javascript
and viceversa
3)how to pass arraylist from c# function to javascript
and viceversa
Please help me out...Expecting your reply...
Thanks
|
|
|
|
|
You did not provide any information pertaining to the hosting process and context for the C# code and the scripting engine. Without that I don't know if anyone would be able to help.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
hi mike,
Thanks for your reply.
I have no. of image filenames in sql database.Using C#, I extracted that data and stored in arraylist.Now I want to store this arraylist object in javascript array.
Is it possible? If yes, please send me sample example.
Thanks
test
|
|
|
|
|
foreach (string name in mylist)
{
Page.RegisterArrayDeclaration("listname", name);
} This will emit the following:
var listname = new Array('a','b','c','d',....);
|
|
|
|
|
hi leppie,
Thanks for your reply.
C# code:
ArrayList c_list = new ArrayList();
c_list.Add("d");
c_list.Add("e");
c_list.Add("f");
Javascript code:
var js_list = new Array('a','b','c');
Now I want to know how to transfer arraylist values from C# to javascript(i.e., c_list -> js_list)
Source -> Destination
C# -> javascript
Please help me to sort out this problem
Thanks
|
|
|
|