|
I have two controls on a form, a label and a text box. The Text box is there just to hold txtfiles (like notepad) and I want to display the line numbers in the label. I've done a quick search here but the only method that I can find is searching for the carriage return charater in the text and then incrementing the line numbers that way; however, this isn't the way I want to do it, because then end of the line isn't always marked with a carriage return. I do NOT want the form to realise that the line has been wrapped and to increment for EVERY line of text.
so for example, if the form was resized, then there would be an increase in the line numbers.
I don't even know how to go about this
jasrus
|
|
|
|
|
I've done a quick search on MSDN and think you'll get the wanted result, if you use a RichTextBox and the following code snippet:
label1.Text = richTextBox1.GetLineFromCharIndex(richTextBox1.TextLength - 1).ToString();
www.troschuetz.de
|
|
|
|
|
I know it is possible to load a file inside a program using stream reader in binary mode, now is it possible read also a directory so get all tha data (its, its files and its subdirecoties).
How could i do?
|
|
|
|
|
|
I'm refferring also to a empty directory, can i read it in binary mode?
|
|
|
|
|
|
Colin Angus Mackay wrote:
If the directory is empty then there is nothing to read. I'm guessing that I am not fully understanding what you are wanting to do. Could you explain the wider problem? For example why do you want to read an empty directory in binary mode?
This was an old DOS technique where you read directories as a binary file, to create tools that hide files, recover deleted files, etc.
Yes, even I am blogging now!
|
|
|
|
|
i have a directory for example Documents, i would understand in real time if someone is creating a new file inside or deleting something.
How?
|
|
|
|
|
Use a file system watcher. This IS in .NET, and afair even by that name "FileSystemWatcher".
Cheers
Sebs
|
|
|
|
|
I'm trying to have visual studio generate my .xml documentation file but for some reason it won't keep the project property "XML Documentation File". When I go into the project properties then go to Configuration Properties -> Build under the property XML Documentation File I type in the location where I want the .xml file then when I press apply it blanks it out. Why can't I set the property? Is there a way to force visual studio to apply the /doc argument?
Please Help,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
You will have to go and apply the settings and reload the project in order the operation to work. Once you reload the project and go to the properties of the Project, you should see everything that you need to update.
|
|
|
|
|
I tried what you suggested but it still won't apply keep the setting or output the .xml file. I've even tried creating a new solution and adding the project to it but it didn't work. What can I do?
Thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
If you are putting a path in front of the .xml file, eg. c:\MyDocuments\VSProjects\MyProject\bin\, then myproject.xml, you are putting the .xml doc in another place where VS can't see it. The IDE is expecting that the myproject.dll and myproject.xml to be in the same place, ie the output path in the project properties, which is usually bin\Debug or bin\Release. Just put the name of the file, which should be exactly the same name as the project dll except the extention.
As for the issue with not having the settings stick, is beyond me. I tried several different approaches this morning and couldn't repeat the problem that you were describing. I do recall a project that gave me the same issue, but when I closed the solution and reopened it, the problem disappeared. I wish that I could be of more assistance.
NDoc might be another alternative to use or http://www.csharpwarehouse.com/Code+Bank/471.aspx[^]
here are some links that may help you out too:
http://weblogs.asp.net/cazzu/archive/2003/12/17/44105.aspx [^]--deals with hardlinks
http://www.squiffler.com/squiffler/article.aspx?id=1[^] --deals with doing web comments
|
|
|
|
|
it works! I tried putting just the filename, like you suggested, and it worked. I guess you can't put in a path + filename even if the path is the same as the project output. That's kind of confusing but at least I got it to work.
Thanks a lot,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
|
Hi!
I am doing some research about COM. I'm about to implements an application with several external dynamic interfaces that should be able to connect to, to be able to get data and/or set data.
The thoughts is to use the OPC standards and as i understand it, most of it is COM related.
My questions are:
Is it possible to write a COM server in c# AND a COM Client in c# that communicates.
I have read about this, but i have found alot of c#->c++ och vice verce. Not a pure .NET -> .NET
the reason of why i want this is to create a program with interfaces that could be implemented by managed as well as unmanaged code. I have tried to use the codes from Nick Parker's and Heath Stewart's articles here at codeproject but i could not get it to work. If i use project->add reference, I get that i can not re-import a type library to a CLR assembly, since it was exported from a CLR assembly.
if i use the the .NET coclass, as should be similar to QueryInteface().
[ComImport, Guid("B58D7C8C-2E2D-4AA6-8EAF-CF7CB448E353")]<br />
class CoClass <br />
{ <br />
}
... I only get:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in WindowsApplication3.exe
Additional information: COM object with CLSID {B58D7C8C-2E2D-4AA6-8EAF-CF7CB448E353} is either not valid or not registered.
Even though this COM object is visible in the OLE/COM obejct viewer and it is searchable in the register.
I have tried gacutil.exe regasm.exe regscvr32.exe but nothing changes anything.
I have tried to implement a .NET COM server with c++ sucessfully
and i have managed to access the system library quartz.dll with .NET implementation.
so i'm starting to think that it is not ment to be possible to .NET -> .NET interop.
or is it ?
appiciate any help
thanks
Andreas Johansson
Software developer
ABB Robotics Sweden
|
|
|
|
|
I am using C# in vs.2003 and have created a windows form that acts as a menu once a user has logged on. The options on the menu differ depending on the users access level. Each option on the menu will call a specific routine that will be contained as a child form on the main form.
I have each routine setup as a class that is compiled into its own dll. Each class is primarily a win form with some database processing.
If I add a using statement for a particular dll in my main form I can then instantiate a class and get the functionality I want but I am planning to have over 1500 of these routines so would like some way of creating instances of these form classes on the fly given a dll name that is stored against a menu item.
Can you point me in the right direction to look for a way of achieving this, or something similar?
Jas.
|
|
|
|
|
Reflection is your friend here, mainly the Assembly class:
Creating an object of a given type from a given assembly[^]
If your classes are stored in separate assemblies I guess they all implement a certain interface, so that they can be instantiated in a uniform manner. If you have already done this, creating an object that implements this specific interface from an assembly is really easy.
Regards,
mav
|
|
|
|
|
Thanks for pointing me in right direction mav!
I have now got it to do what I want. This is the code I have:
Assembly asm = Assembly.LoadFile(filename);
Type[] types = asm.GetTypes();
Form frm = (Form)Activator.CreateInstance(types[1]);
frm.MdiParent = formp;
frm.Show();
Where 'formp' is the parentform.
I also found this article useful
http://www.thecodeproject.com/csharp/SuiteApp.asp
|
|
|
|
|
hi all. I am doing a project in c#. It has to capture and inject packets. I am using winpcac and libnetNT respectively for doing the same. the problem i am facing is with the structures.
the built-in function of libnetNT (libnet_write_link_layer())uses as arguments a structure pointer. the function is using the contents of the structure, and it also writes in the structure.
had it only writing in the stuctures, i could have used IntPtr.
what can i do?
one who feels he is too small to make a difference has never been in bed with a mosquito
|
|
|
|
|
Hi all
I am serializing an object to memory stream using XmlSerializer. My problem is after serializing the whitespace values of properties in the objects are converted to null in the memory stream. Is there any way I preserve the the whitespace values during serialization.
Thanx & Best Regards
Pradosh Anandan
|
|
|
|
|
Is there a way to hide a window and still keep the message pump running?
|
|
|
|
|
Hi all,
I have a queston on code obfuscation in C# as follow,
If the code contain string, say
String a = "apple";
Will the "apple" be also obsfucated into another string by the obsfucator ?
Thanks
|
|
|
|
|
Not really, otherwise you would lose the string information. I suggest to use a database, which holds the original string and is called by an own module ( as used in multilanguage applications ).
|
|
|
|
|
Hello C#-Comunity!
I have a little problem using Reflection under C#.
I defined an abstract class with a static method in an assembly '.dll'-file.
In source code it looks like:
<br />
<br />
public abstract class MyClass<br />
{<br />
<br />
<br />
public static int MyStaticMethod(int paraNumber)<br />
{<br />
}<br />
<br />
}<br />
<br />
This code is compiled as a '.dll' file. Then it´s not implemented via Reference in Visual Studio, but as an reflection-load with the
'System.Reflection.Assembly.LoadFile(...)' - statement.
My problem is to invoke the static method in this abstract class via reflection.
With the statements:
<br />
<br />
Type MyMetaObject = assembly.GetType("MyClass", true, true);<br />
<br />
object[] parameters = new object[1];<br />
parameters[0] = (object) paraNumber;<br />
<br />
object retObject = MyClass.("MyStaticMethod", System.Reflection.BindingFlags.InvokeMethod, null, ?X?, parameters);<br />
<br />
This doesn´t work
I think the problem is the '?X?', because I tried it with 'null', but it causes a runtime error like 'Object reference is not set to an instance of object' [or something like that].
Normally the '?X?' parameter is for an instance of the object which method will be invoked, but I can´t create an instance from an abstract class object!
Has anybody some solution proposals?
Thanx for any help!
Ciao
Norman-Timo
|
|
|
|