|
This was anwserd so many times in thsi forum ...
Search a little.
But the idea is to pass a refrence of the form with the textvox to the form that wants to change that textbox in the constructor.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
|
Thanks, but what if I didn't create the class for the textbox I want to send to. For example, if I wanted to send info to a text box in a web browser, where I can start the process with the Process class, but how would I access a reference to it?
|
|
|
|
|
That's been answered many times as well. You need to get a handle to the process (see the System.Diagnostics.Process class in the .NET Framework SDK) then P/Invoke FindWindow and FindWindowEx to get the window handle (HWND - represented by an IntPtr in .NET) of the control. Then you can P/Invoke SendMessage to send WM_SETTEXT to the HWND with the text you want to set. Search this forum for more information, and see the Platform SDK for details. Previous experience with Windows messaging will definitely be a plus.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks alot I saw your previous post with the code. I searched for this, but I wasn't getting back results that applied to what I wanted to do, I guess the keywords I was searching for weren't specific enough.
K
|
|
|
|
|
Hi,
What is the best way to store encripted passwords?
I'm using a simple XML file to store the passwords but I don't know how to store the key used in encriptation in a safe way.
The passwords are to connect to a database, so they need to be tranformed back to the original values.
Thanks
|
|
|
|
|
You might want to look up documentation of the following method. I think it is what you are looking for
FormsAuthentication.HashPasswordForStoringInConfigFile
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
DrGreen wrote:
The passwords are to connect to a database, so they need to be tranformed back to the original values.
That's not a good way to do it. You should store passwords in a one-way hash (like MD5) which someone else mentioned. Instead of sending clear-text passwords across the wire (which can be easily sniffed) and decrypting the passwords from the database to compare, a much more secure approach is to hash the clear-text password and compare that with the password in the database. This can be done better by using a SALT value and other mechanisms to avoid replay attacks.
There are several articles about this here on CodeProject.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
can anyone tell me to create a prev/next in datagrid. I would like to display record in a datagrid with multiple pages.
thank You
|
|
|
|
|
I take it this is in reference to ASP.NET's DataGrid ? If so, this belongs in the ASP.NET forum. Really, though, the documentation is pretty clear about how to do this and even includes examples.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
In general you are talking about pagination, maybe a google on "datagrid pagination" is in order.
if you are referring to asp.net, research the following properties of the datagrid;
AllowPaging
AllowCustomPaging
event:
PageIndexChanged
Good luck!
R.Bischoff
.NET, Kommst du mit?
|
|
|
|
|
Hi
I want to be able to create an Type from an string.
I have tried using Type.GetType(string). But I just cant get it too work.
Im getting assembly not found in msorlib thing or the executing assembly errors.
Im trying to get the Type from for example Type.GetType("TextBox"). But this dont work since the program doesnt seem to know where to look.
How can I load the System.Windows.Forms assembly so it knows where to look?.
|
|
|
|
|
Have you tried Type.GetType("System.Windows.Forms.TextBox") ?
|
|
|
|
|
Yes and I allways get an TypeLoadException.
The problem is that the Type.GetType method searches the executing assembly in this case an testlibrary.
"An unhandled exception of type 'System.TypeLoadException' occurred in xmltestlibrary.dll
Additional information: Could not load type System.Windows.Forms.TextBox from assembly TestLibrary, Version=1.0.1589.1600, Culture=neutral, PublicKeyToken=null."
|
|
|
|
|
Then you have to force .NET to load the correct assembly:
<br />
String name = System.Reflection.Assembly.CreateQualifiedName("System.Windows.Forms", "TextBox");<br />
<br />
System.Reflection.Assembly a = System.Reflection.Assembly.LoadWithPartialName("System.Windows.Forms");<br />
<br />
Type t = a.GetType("System.Windows.Forms.TextBox", true, false);<br />
|
|
|
|
|
Thx it worked like a charm.
|
|
|
|
|
And after you get the Type like Corrina said, then you can use a number of ways to instantiate it, like Activator.CreateInstance . See the .NET Framework SDK documentation for more ways, like getting the constructor with a certain parameter list and calling that to create a new instance with the parameters you want.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know that. Then I can use various methods to be able to execute methods.
I can even load an unknown dll and search it find and class and call methods.
So I know about the capabilities.
As I replied to Corrina.
Yes and I allways get an TypeLoadException.
The problem is that the Type.GetType method searches the executing assembly in this case an testlibrary.
"An unhandled exception of type 'System.TypeLoadException' occurred in xmltestlibrary.dll
Additional information: Could not load type System.Windows.Forms.TextBox from assembly TestLibrary, Version=1.0.1589.1600, Culture=neutral, PublicKeyToken=null."
I dont get it. I've looked at examples but they arent very helpfull.
|
|
|
|
|
Notice how it's trying to load a Type that should be in the System.Windows.Forms.dll assembly? You have to specify a correct partial or full Type, like:
Type t = Type.GetType("System.Windows.Forms.TextBox, System.Windows.Forms"); Notice the assembly name in there, too? If you want to get specific, you can also include the version, culture, and publicKeyToken attributes.
There are plenty of examples - even in common .config sections do you specify the fully-qualified Type name and either a partial of full assembly reference. If you don't specify the assembly, then it assumes the Type name is in the currently executing assembly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
HI!
I want to detect CPU usage and Net speed using PerformanceCounter, but the vaules are always 0.
For net speed here is the code:
private void GetNetSpeed()
{
PerformanceCounterCategory category = new PerformanceCounterCategory("Network Interface");
foreach(string adapter in category.GetInstanceNames())
{
if(adapter == "MS TCP Loopback interface")
continue;
PerformanceCounter netRCounter = new PerformanceCounter("Network Interface","Bytes Received/sec",adapter);
PerformanceCounter netSCounter = new PerformanceCounter("Network Interface","Bytes Sent/sec",adapter);
txtSys.Text += "Recived: " + netRCounter.NextValue().ToString() + " b/s.";
txtSys.Text += "Sent: " + netSCounter.NextValue().ToString() + " b/s.";
}
}
Could anybody tell me way is always 0?
HELLO!
|
|
|
|
|
would like to know how to get hold of excel cells using the Excel namespace?
Is there anyone with ideas, I need to read a lot of data and manipulate it from a spread sheet.
thanks
Dries
|
|
|
|
|
Use the Microsoft PIAs (Primary Interop Assemblies) that can be downloaded from http://msdn.microsoft.com[^] for Office XP or that come on the CD with Office 2003 Professional. Add a reference to Microsoft.Office.Interop.Excel.dll and create a new instance of the ApplicationClass in the Microsoft.Office.Interop.Excel namespace. This creates a new instance of the Excel application (invisible at first - set its Visible property to true to display it).
Then load a new workbook or template using Workbooks.Open . That will give you a Workbook instance. Cast this to a WorkbookClass and use the Sheets property to get the Sheet you want. Use the Item property to get a Worksheet . Cast this to a WorksheetClass and you can now get the Cells property. This is all documented in the Office Programming Reference what to do and where to go from there (like the various ways you can reference cells).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
i have two classes, one serverCommands and one socketServer. once i have created a new instance of the serverCommands class in socketServer, i want to be able to type something like serv (my new instance of serverCommands) .CreateSocket(socketName) and create a socket according to the name specified. is this possible?
if so, how? this could be used with other stuff two as there is some things that would be much quicker to create with a function. should the functions be private, public, static or what? (and what do they mean? )
also is it possible to say something like Console.WriteLine(serv.Version()); and have it getting an output from the function Version and displaying it in the Console? i understand references have something to do with this, and returns...
thanks for help with any of the above,
surgeproof
-------------------------------------------------------
ithium is the best.
'Science without religion is lame, religion without science is blind.' --Albert Einstein
'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
|
|
|
|
|
This is all possible if you design your application right. It's your implementation.
As far as the access modifiers, you need to decide if you want any class to be able to call a method or get/set a property or not. You can see the differences between the access modifiers by reading Access Modifiers[^] in the Visual C# product documentation.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for the link, it helps. would you have a link to teach me about functions/etc. and referencing? i can't seem to find anything useful, so if you do know of a good one please tell.
thanks,
surgeproof
-------------------------------------------------------
ithium is the best.
'Science without religion is lame, religion without science is blind.' --Albert Einstein
'The pioneers of a warless world are the youth who refuse military service.' --Albert Einstein
|
|
|
|