|
Hi everyone..
I have a problem creating a AxMsComm list. This is my code:
<br />
public static List<axmscommlib.axmscomm> lstModem = new List<axmscommlib.axmscomm>();<br />
lstModem.Add(new AxMSCommLib.AxMSComm);<br />
lstModem[0].Enable = True;<br />
lstModem[0].Tag = -1;<br />
lstModem[0].CommPort = 1; <br />
.<br />
.<br />
While I am running my aplication I get the following exception:
<br />
InvalidActiveXStateException<br />
I searched for this in google and I found that this is because .NET doesn't allow to create new COM objects dinamically.
Is this true? Does anyone know a workaround of this?
Any help would be apreciated! Excuse my English if I made a mistake.
Ivan.
|
|
|
|
|
If it is a serial port you need, why don't you use the SerialPort class?
|
|
|
|
|
I was wondering that too !
Its not my fault! This aplication is implemented in this way
|
|
|
|
|
Is it possible to run an embedded WSF script?
I know I can run the script if it is external to the program with the System.Diagnostics.Process class but I would like to make this a standalone exe so it is portable.
any code examples would be great or the class I should research more.
thanks
|
|
|
|
|
Hello
I am trying to display the names of all the .rpt files in the reports directory in a gridview. I also need the file name to act as a link to open the .rpt file. So far the code below returns all of the file information in the gridview but I need to filter out just the file name and turn it into a link.
DirectoryInfo di = new DirectoryInfo("C:/Inetpub/wwwroot/Reports");
FileInfo[] rgFiles = di.GetFiles("*.rpt");
gvReportList.DataSource = rgFiles;
gvReportList.DataBind();
foreach (FileInfo fi in rgFiles)
Any help would be greatly appreciated.
John
|
|
|
|
|
like this
void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if(File.Exists(listBox1.SelectedItem.ToString()))
System.Diagnostics.Process.Start(listBox1.SelectedItem.ToString());
}
void getDirectories()
{
DirectoryInfo di = new DirectoryInfo("C:\\");
foreach (FileInfo f in di.GetFiles("*.txt"))
{
listBox1.Items.Add("C:\\" + f.ToString());
}
}
Oops that's with a listbox. Well it shouldn't be too hard to do that with a gridview anyway.
|
|
|
|
|
Thanks for the quick reply. Your correct that it should'nt be too hard to do with a grid view but I am so new to this that for me it is hard. Any more explanation would be greatly appreciated.
|
|
|
|
|
Yeah sorry I didn't but alot of effort into explaining that
getDirectories is called at the beginning of your app
DirectoryInfo di = new DirectoryInfo("C:\\");
^^You have this done already
foreach (FileInfo f in di.GetFiles("*.txt"))
{
listBox1.Items.Add("C:\\" + f.ToString());
}
^^This gets all the files you want in the directory and adds them one by one to the listbox with the address of the files you have found
void listBox1_SelectedIndexChanged(object sender, EventArgs e)
^^This is the event handling method which occurs when you click on one of the items in the listbox
if(File.Exists(listBox1.SelectedItem.ToString()))
^^This makes sure that the file actually does exist before opening it- so it won't cause an exception
System.Diagnostics.Process.Start(listBox1.SelectedItem.ToString());
^^This opens the file(from the name of the listbox item you have clicked) with whatever program is the default for it's file type. i.e *.txt with notepad...
|
|
|
|
|
Hi All....
How can i use MAX() function in XPath.
1) By Googling... showing comparing node values.. some thing like
/root/node[not(@val <= preceding-sibling::node/@val) and not(@val <=following-sibling::node/@val)]
2) But I want to work like this
xd.SelectNodes("max(//dgn/one/@id)");
from the reference
http://www.w3schools.com/xpath/xpath_functions.asp#anyuri
Any Idea...?
Thx for the time.
Enjoy!!
Siddharth
|
|
|
|
|
I've got a C# Windows app with an Adobe PDF Reader Control in one of the forms. I'm using acrobat to place buttons in the PDF that will be viewed. I need some way to make the button click in the PDF to be registered as an event in my C# app. I'm having a hard time figuring out how to do this. Would this be easier with an Adobe Acrobat control instead of Reader??? I understand that it might be necessary to put some Javascript in the PDF that runs when the button is clicked and then reference it through my C# (a document level function???). If anyone can guide me in the right direction, it would help immensely.
Any help would be greatly appreciated and please keep in mind that I'm pretty new to C# and know nothing at all about JavaScript.
Thanks,
Engineer Joe
|
|
|
|
|
Where did you get the adobe pdf reader control?
If you create an click event handler for the control it should register when you click it.
Wait now.... that was stupid!
modified on Thursday, April 16, 2009 12:26 PM
|
|
|
|
|
got the control by adding reference under Project ---> Add Reference. Chose something like AcroPDFLib from the COM tab. Then right-clicked the toolbox, choose items, and chose Adobe Reader. In my code, I open the appropriate PDF. So I get the PDF to open with no problem. Now I have to get it to register a button click in the PDF. Problem is that it has to be done at runtime, and i'm also not sure adobe provides a way to reference the event through C#. I'm not that great with event handlers...til now i've just chosen them from the menu options...but that's not possible with a button that isn't present until runtime... I've seen some some code that supposedly runs a javascript function in a PDF when a button is clicked, and i hoping that I could create an event like that somehow.
Sidenote: I'm amazed at how very little functionality the Adobe Reader control has. I haven't found a way to actually get the X, Y, and Zoom coordinates of the viewing window... They can be set easily enough, but I haven't found a way to GET them.
|
|
|
|
|
Take a look at this[^] then check if the click is inside the pdf control.
Hope this helps
|
|
|
|
|
While this can tell me everything about the mouseclick, i can't find how it will tell me anything about a button being pressed... There's no way for a mouseevent itself to convey what button was pressed. It seems that the original problem of not being able to identify a button in a PDF is the problem... Maybe I should repost the question in that manner...My subject title is misleading now that i know more about the subject. Thank you for the reference to this tool though. I can see it being useful for me in the future.
jpc
|
|
|
|
|
Hi
How to convert System.Type to Form ?
i wrote this code :
FormsCollection forms = new FormsCollection();
foreach(Type t in types)
{
if (t.BaseType == typeof(Form))
{
Form frm = (Form)t;
forms.Add(frm);
}
}
but, the following error message display :
Cannot convert type 'System.Type' to 'System.Windows.Forms.Form'
How to solve this problem ?
Thanks
|
|
|
|
|
I don't understand what it is you are trying to do (what is types?) but you could consider if (t is Form) forms.Add(t as Form);
|
|
|
|
|
You will need to instanciate a new Form in your if block, a Type is a Type, not an object so it can't be cast.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
DaveyM69 wrote: a Type is a Type, not an object so it can't be cast.
Type is an object (System.Type[^]), just not an object of type Form.
|
|
|
|
|
A Type describes the class (or enum, or whatever). It is not the class itself. You need to use Activator.CreateInstance in order to get the actual class
|
|
|
|
|
Hi guys!
I'm new to network programming so i'm sorry if this question is a little noobish. I started using the WebBrowser Control in c# and so far it has done my purpose. But I want to know if there is a way to utilize this same control (so I won't change my code) without the visual display. Is it possible to "hide" the control but letting it stay active? Or is there a usable base class where the WebBrowser inherits its properties and methods?
Thank you guys!
|
|
|
|
|
You could try setting the Visible property to false. You could instantiate it, but not add it to the Controls collection. If you wanted to, you could even use a HttpWebRequest to get a webpage's source
|
|
|
|
|
My first intuition was to set the visibility to false, but then it turns out that doing so disables the whole control and thus the rest of my code wont work. What do you mean by "You could instantiate it, but not add it to the Controls collection"?
Btw, I tried to instantiate it instead of adding it the control from the designer by the code: webBrowser webBrowser1 = new webBrowser(); However, it didn't work in this manner. I also can't seem to find a property that would let it not display.
I also have a code using HttpWebRequest and HttpWebResponse, but its a lot longer and I don't know how to send multiple posts and how to activate a button click...
|
|
|
|
|
I got it, there was this code: this.Controls.Add(this.webBrowser1) that adds the control to the windows form, All I had to do is comment it out.
Thanks for the help!
|
|
|
|
|
Hi,
I would like to know if I can include a progress bar when I'm trying to copy files from one location to another with :
1. The file count unknown to me.
2. The size of each file is unknown to me.
For the above conditions, I'm able to get the normal progress bar which shows progress between the starting and final positions repeatedly.
The question is whether I can use a progress bar that shows the overall progress, just like the windows file copy progress bar...
Can anyone help me on this?
Thanks in advance,
ramzg
|
|
|
|
|
if you don't have the numeric information, you can't show progress information, all you can do is indicate it is still busy.
so figure out what you mean by progress, and once you know how to do it by hand, you can create some code that does the same.
|
|
|
|