|
Use the link label object.
|
|
|
|
|
Hi,
i am not so long on c#. I want to get the input on the com1-Port by a Barcode-Scanner into my Text Field on my form. Can somebody help me??? thnx
Viedy
P.S.: Sorry, my English is not so good
|
|
|
|
|
Hi WiB,
thank you for your answer, but this is not really what I want. Is there a Com-Object or anything else to communicate with serial-Ports??? I haven´t found anything in my Toolbox.
|
|
|
|
|
|
You must to open a file using the name "COM1" in file name
Best Regards
Carlos Antollini.
Pi Five[^]Creator
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hello
Any one have idea how to create or remove dsn
programatically in c#.Plz help..
Faisal Nadeem
Software Engineer
|
|
|
|
|
look for API SQLConfigDataSource in MSDN
or buy http://www.pardesifashions.com/Softomatix/OdbcNetTools.aspx
|
|
|
|
|
Hi All
I'm using a SaveFileDialog to get a filename from the user. I've create a list of filters, but at the point where I try to save the file I still have to create a very dirty switch over the filterindex. Does anybody now cleaner way to implement this?
thx in adv.
|
|
|
|
|
The cleanest way to do this is to use the ImageCodecInfo class, and some reflection on the ImageFormat class. The code isn't simple, but you won't need to update it if new formats are added. Just call ImageUtils.GetImageFormatForFile , pass in the selected file name, and the function will return the correct ImageFormat object.
using System;
using System.IO;
using System.Reflection;
using System.Drawing.Imaging;
public class ImageUtils
{
public static ImageFormat GetImageFormatForFile(string filename)
{
if (null == filename || 0 == filename.Length)
throw new ArgumentNullException("filename");
int index = filename.IndexOf('.');
string ext = (-1 == index) ? filename : filename.Substring(index + 1);
ext = "*." + ext;
ImageCodecInfo info = null;
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
for(int i=0; i<codecs.Length && null == info; i++)
{
string[] extensions = codecs[i].FilenameExtension.Split(';');
for(int j=0; j<extensions.Length && null == info; j++)
{
if (0 == string.Compare(extensions[j], ext, true))
info = codecs[i];
}
}
if (null == info)
return null;
else
return GetImageFormat(info.FormatID);
}
public static ImageFormat GetImageFormatForMime(string mimeType)
{
ImageCodecInfo info = null;
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
for(int i=0; i<codecs.Length && null == info; i++)
{
if (0 == string.Compare(codecs[i].MimeType, mimeType, true))
info = codecs[i];
}
if (null == info)
return null;
else
return GetImageFormat(info.FormatID);
}
public static ImageFormat GetImageFormat(Guid formatID)
{
Type tImageFormat = typeof(ImageFormat);
PropertyInfo[] props = tImageFormat.GetProperties(
BindingFlags.Public | BindingFlags.Static);
for(int i=0; i<props.Length; i++)
{
PropertyInfo prop = props[i];
if (tImageFormat == prop.PropertyType)
{
ImageFormat fmt = (ImageFormat)prop.GetValue(null, null);
if (fmt.Guid == formatID)
return fmt;
}
}
return new ImageFormat(formatID);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hello,
I'm using the WebBrowser control in an application in C#.
I created an UserControl embedding the WebBrowser control.
I have a form including one of this UserControl.
I also have a thread that makes calls to the Navigate()
method of the WebBrowser control. This thread
automatically navigate to several hundred of pages and
sites. It waits for several minutes for a page to load and
then traverse its DOM.
Everything works nicely but after a while (time vary, page
involved too) I always get a COMExption error when calling
the Navigate() method: "Requested resource is in use".
I'm really stuck with this problem which compromise the
program stability. Any help or ideas will be greatly
welcome.
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
Probably the urlmoniker has not finished to download the current web page. And, for some reason, the next Navigate() call reuses this underlying object.
A few advices, although I haven't tested any of them :
- release the underlying COM object (Marshal.ReleaseComObject()).
- cast the current document to IMoniker and free it. (the moniker is a url moniker obtained when you navigate a url, and it does an underlying COM CreateURLMoniker(...) ). See MSDN / WalkAll for more info.
- cast the current document to IPersistStream and free it. Try also with IAsyncMoniker. Both of the interfaces must be declared before used. Read my recent posts about IPersistStreamInit for more info.
|
|
|
|
|
Hello Stephane,
Thank you very much indeed.
I'm going to look into these objects.
If you have any other idea or anybody else, feel free to post here.
Thanks,
R. LOPES
Just programmer.
|
|
|
|
|
Hello,
I can't find in C# any of data components like dbTextEdit,
dbComboBox, dbLookupComboBox, dbRadioButton, dbCheckButton , dbTreeList...
My main programm tool is Delphi so I'm very confused about some
things in C#. What is solution about this problem.
Thank you for answers.
Anze
/*Sorry about my English*/
|
|
|
|
|
Hi,
You will find that in .NET TextEdit, ComboBox, etc.. (pretty much every control) support DataBinding, which would get (kind of) the same functionality. (I don't think TreeView support DataBinding).
Hope this helps.
Andres Manggini.
Buenos Aires - Argentina.
|
|
|
|
|
can you write me a small example, or if you know some links to articles about databinding.
thank you
|
|
|
|
|
|
help me, how to write Listbox in webcontrol, I see ListBoxMultiCol in this but It write for window Form
someone, can help me to do this???
thanks
Ps : what's the protected method to draw Item on ListBox???
Nho'c ti`
|
|
|
|
|
I'm trying to extract links frome a webpage by mshtml.Now I'm eager for help.
The following code can be reffered: (most from .S.Rod)
[ComImport, Guid("7FD52380-4E07-101B-AE2D-08002B2EC713"),InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IPersistStreamInit
{
IntPtr GetClassID();
void IsDirty();
void Load(IntPtr pStream);
void Save(IntPtr pStream, bool fClearDirty);
long GetSizeMax();
void InitNew();
}
private void LinkExtractor()
{
mshtml.HTMLDocumentClass docCls=new mshtml.HTMLDocumentClass();
IPersistStreamInit pS = (IPersistStreamInit) docCls;
pS.InitNew();
docCls.createElement("<a href='http://www.codeproject.com'>link</a>");
//the following code is to get bodyElement,but failed
int i=0;
for(i=0;i<5;i++)
{
object oIndex=(object)i;
if(i==3)
{
System.Type type=docCls.all.item(oIndex,oIndex).GetType();
mshtml.HTMLBodyClass bodyCls=(mshtml.HTMLBodyClass)docCls.all.item(oIndex,oIndex);
}
}
}
Now I wonder how can I get the bodyElement,by which can easily extract all links of a webpage.
|
|
|
|
|
Hello Benzite,
- if you create a HTMLDocument instance, then it's like an empty web page. Before you can browse the tree of tags, you have to fill the HTMLDocument. That's the reason why you don't find any <body> element.
- to fill the DOM, you could use IPersistFile.Load(filepath), IUrlMoniker(url). Or, may be simpler, something David Stone has pointed out in this forum a couple of days ago : he uses the WebClient class to download the web page and get the source code. Now you can use the web page you have just retrieved and pass it as a parameter to HTMLDocument.write(...).
Good luck!
|
|
|
|
|
Thanks,you have given me a lot of help!
I have use the WebClient class get the webpage's source code. When use HTMLDocument.write(params[] object psarray),I don't know the content of psarray,and how to build psarray from the source code.Can you tell me somthing about psarray.
|
|
|
|
|
My recommendation is to use this code :
using System.Net;
using System.Text;
<p> </p>
mshtml.HTMLDocumentClass doc = new mshtml.HTMLDocumentClass();
IPersistStreamInit pS = (IPersistStreamInit) doc;
pS.InitNew();
WebClient client = new WebClient();
byte[] data = client.DownloadData("http://www.microsoft.com");
doc.body.innerHTML = ASCIIEncoding.ASCII.GetString(data);
|
|
|
|
|
Wonderful! The body element has been built.
Can you tell me the reason use the following sentence?
IPersistStreamInit pS = (IPersistStreamInit) doc;
thanks.
|
|
|
|
|
It's COM's queryinterface. Since doc is a IHTMLDocument2 interface, the only way to be able to call a IPersistStreamInit interface method is to query for the interface first, and then call the method. In C#, queryinterface is just a cast, hence the (IPersistStreamInit) . (the CLR manages the underlying COM queryinterface).
|
|
|
|
|
thanks
|
|
|
|
|
benzite wrote:
Now I wonder how can I get the bodyElement,by which can easily extract all links of a webpage.
To extract all links, you only need to access the anchors collection : docCls.anchors.length , docCls.anchors.item(i) .
|
|
|
|