|
Your class can contain something like this...
public class MyClass
{
public void MyMethod(System.Windows.Forms.Control theControl)
{
}
}
From the Form (I'm assuming this is where you are coming from, you've not been very explicit about this) something like this....
public void SomeMethodInTheForm()
{
MyClass theClass = new MyClass();
theClass.MyMethod(this.theTextBox);
}
Voilá.
Does this help?
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
This is exactly what I'm looking for. Thank you very much.
|
|
|
|
|
I have a tab control on my form which can resize. The tab control itself is ancored and resizes ok. Each tabPage has a few buttons whcih get resized ok to a point. The active tabPage control's buttons reisze ok, but then switching to another tabPage I find that the buttons raen't in the correct horizontal positions. If I resize the form again the 2nd tabPage which had the buttons repositioned incorrectly will position the buttons ok, but switch back to the 1st tabPage and it's buttons are now in the wrong place!!!
I have tried embedding each button in its own panel control and ancoring the button left & right to its parent panel and the panel itself being anchored bottom & left and the other panel with embedded button bottom & right. This doesn't work either and it seems that the anchoring only works for the active tabPage.
I have also tried postioning the buttons in the resize event which only works fine for the active tabPage.
Has anyone else come accross the problem of correctly resizing buttons which need to grow their width property in proportion to the tabPage width? I am leaving the height unchanged. Anyone know of a way to correctly adjust the width and left properties correctly for non active tabPage's?
For the record I have about 6 tabPages, some have only two buttons adjacent to one another, other tabPages have five buttons adjacent to each other. In each tabPage the buttons need to increase/decrease their width property and adjust their left property also.
I have run out of ideas. And no I can't leave the width properties as static.
|
|
|
|
|
Hi,
Late last night I found a great C# example on thecodeproject.com and downloaded the demo (not the source). It was a c# custom control that drew colored buttons (and switched the images when clicked). They were roundish -- oblong, not circular. Now, in the light of day I can't find the project and I'd really like to see the source code. The file I downloaded was ColorButtonExample.zip, but I've searched for those words and can't find that example again.
If any of you know what I'm talking about and could send me the link I'd really appreciate it.
thanks,
Deanna
|
|
|
|
|
Hi,
do you mean this:
Custom Button with Color and Shape[^]
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
THAT's IT!! Thanks, Gary. I'm living proof that too much Aspartame (Diet DP) can rot your brain!
thanks so much,
Deanna
|
|
|
|
|
Anonymous wrote:
THAT's IT!! Thanks, Gary. I'm living proof that too much Aspartame (Diet DP) can rot your brain!
thanks so much,
Deanna
Your brain can't be too bad if you can remember the name "Asparame", sound like a Disney character
Gary
"2400 Baud makes you want to get out and push !"
|
|
|
|
|
I want to have a edit menu with the usual cut copy paste functions but I am not sure how to write the generic code for doing this. I want it to operate the same as when you right click on a text box. Can anyone point me in the right direction?
Thanks so much!
|
|
|
|
|
There lots of articles here on CodeProject that discuss undo/redo functionality using a variety of methods from structured commands to handled page faults. I suggest you try a search.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Also if you use a RichTextBox, they support Undo / Redo operations.
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
Undo feature of RichTextBox has bug. Undo information is lost once you get the text using Text property i.e. richTextBox.Text .
Please refer the following article for detail.
Microsoft Knowledge Base Article-812943
Regards,
Jay.
|
|
|
|
|
Hi,
A while back I was reading about passing parameters to C# properties and loving it. But I must have been dreaming because now (that I'm ready to use them) I can't find any mention of them. Was it only a dream?
Thx,
MAtt
|
|
|
|
|
No, you can pass parameters like this (excuse the pun)
public MyObject this[int index]
{
get
{
return (MyObject) InnerList[index];
}
}
as you can see I've ripped this code from a CollectionBase derived class.
You can pass more than one param within the [] brackets
Gary
"A fellow with the inventiveness of Albert Einstein but with the attention span of Daffy Duck."
Tom Shales talking about Robin Williams
|
|
|
|
|
hello forum,
i have defined a web service. If the remote operation is successful the method must return a type of datum (for example, struct Okstr) but if the remote operation is not successful the method must return another different type of datum (for example, ERRORstr).
How Can i do this with Web Services??
Is possible to throw exceptions via Web Services (like JAVA RMI or CORBA)?
A lot of thanks!!
|
|
|
|
|
Yes, you can throw SoapExceptions using XML Web Services. One way of doing this if you do not want to throw exception, is to create error object of required type like ( Struct in this case ). If web service is successful return the data object else return your error object. In this case, the return type of your web method can be struct or any type you want.
Bhaskara
|
|
|
|
|
thank you... but i dont know how can i define (with visual studio .Net) a web service that can return two different types.
In SUN RPC's I used a union with its discriminator to do this, but there's no union in C#.
Can you help me?
thanks in advance!
|
|
|
|
|
Hi All,
Hopefully this is the right place to post this question. I have a project where I am creating SSRS reports on my machine and deploying them to another machine that has the databases on them along with SSRS. Only the 1.1 framework for dot net is on that machine. This one report where I've added a web application and am referencing a reportViewer.dll of which "Microsoft.Samples.ReportingServices" is the namespace is giving me this message. I'm kinda new to C# and SSRS so any help as to where to fix this problem would be of great help. Below is the error message. Thanks In Advance
Parser Error Message: File or assembly name ReportingServicesWebServer, or one of its dependencies, was not found.
Source Error:
Line 26: <assemblies>
Line 27: <clear>
Line 28: <add assembly="ReportingServicesWebServer">
Line 29:
Line 30:
Source File: G:\Application\MSSQL\Reporting Services\ReportServer\web.config Line: 28
Assembly Load Trace: The following information can be helpful to determine why the assembly 'ReportingServicesWebServer' could not be loaded.
=== Pre-bind state information ===
LOG: DisplayName = ReportingServicesWebServer
(Partial)
LOG: Appbase = file:///C:/Inetpub/wwwroot/WebPrintTest
LOG: Initial PrivatePath = bin
Calling assembly : (Unknown).
===
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: ReportingServicesWebServer
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/reportserver_printtest/c126663c/7a3a6a93/ReportingServicesWebServer.DLL.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/reportserver_printtest/c126663c/7a3a6a93/ReportingServicesWebServer/ReportingServicesWebServer.DLL.
LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/WebPrintTest/bin/ReportingServicesWebServer.DLL.
LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/WebPrintTest/bin/ReportingServicesWebServer/ReportingServicesWebServer.DLL.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/reportserver_printtest/c126663c/7a3a6a93/ReportingServicesWebServer.EXE.
LOG: Attempting download of new URL file:///C:/WINNT/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files/reportserver_printtest/c126663c/7a3a6a93/ReportingServicesWebServer/ReportingServicesWebServer.EXE.
LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/WebPrintTest/bin/ReportingServicesWebServer.EXE.
LOG: Attempting download of new URL file:///C:/Inetpub/wwwroot/WebPrintTest/bin/ReportingServicesWebServer/ReportingServicesWebServer.EXE.
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
later,
Clyde
|
|
|
|
|
Hi there,
I was wondering if someone knows the C# equivalent for charCodeAt. This is een JScript method
that converts an string to Unicode and encodes this at base 16 (toString(16))
This project generates strong (WEP) key's for protecting WIFI access points.
Anyone got a clue??
Help would be appreciated!
This is the original JScript source
// generate a WEP key with the specified key length in bytes
//(5/13/16/29 bytes for 64/128/152/256-bit WEP
function gen_key(keyLengthInBytes) {<br />
for (i = 0; i < keyLengthInBytes; i++)<br />
{<br />
ascWEPkey += charArray[gen_prn()]; <br />
}<br />
<br />
for (i = 0; i < ascWEPkey.length; i++)<br />
{<br />
hexWEPkey += ascWEPkey.charCodeAt(i).toString(16);<br />
}<br />
}
This is what i got so far
private string ASCII_KEY, HEX_KEY;<br />
private char[] charArray = new char [95] { <br />
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')','*', '+', ',', '-', '.', '/', <br />
'0', '1', '2', '3', '4', '5', '6', '7','8', '9', ':', ';', '<', '=', '>', '?', <br />
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', <br />
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', <br />
'\'', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', <br />
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'};<br />
<br />
private void GenerateWEPKey(int KeyLength) {
for (int i = 0; i < KeyLength; i++) {<br />
ASCII_KEY += charArray[GenPseudoNo()];
}<br />
for (int i = 0; i < ASCII_KEY.Length; i++) {<br />
HEX_KEY += charCodeAt(ASCII_KEY,i);
}<br />
MessageBox.Show(HEX_KEY);<br />
}<br />
<br />
private int GenPseudoNo() {<br />
Random rdm = new Random();
return (int)Math.Floor(rdm.NextDouble() * charArray.Length);
}<br />
<br />
private string charCodeAt(string ASCII, int index) {<br />
System.Text.ASCIIEncoding AE = new System.Text.ASCIIEncoding ( );<br />
byte [ ] alphabetArray = AE.GetBytes ( ASCII );<br />
System.Text.StringBuilder sb = new System.Text.StringBuilder();<br />
<br />
for ( int x = 0; x <= alphabetArray.Length - 1; x++ ) {<br />
sb.Append ( string.Format ( "{0}", alphabetArray [ x ]));<br />
}<br />
return sb.ToString(index,2);<br />
}
Mark van den Broek
mvdbroek@kg.nl
|
|
|
|
|
String 's in .NET are Unicode. To covert to hex format, use the "X" as defined by the NumberFormatInfo class.
string val = 114.ToString("X");
int num = Int32.Parse("126", System.Globalization.NumberStyles.HexNumber);
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi there,
I was wondering if someone knows the C# equivalent for charCodeAt. This is een JScript method
that converts an string to Unicode and encodes this at base 16 (toString(16))
This project generates strong (WEP) key's for protecting WIFI access points.
Anyone got a clue??
Help would be appreciated!
Mark van den Broek
mvdbroek@kg.nl
This is the original JScript source
// generate a WEP key with the specified key length in bytes
//(5/13/16/29 bytes for 64/128/152/256-bit WEP
function gen_key(keyLengthInBytes) {<br />
for (i = 0; i < keyLengthInBytes; i++)<br />
{<br />
ascWEPkey += charArray[gen_prn()]; <br />
}<br />
<br />
for (i = 0; i < ascWEPkey.length; i++)<br />
{<br />
hexWEPkey += ascWEPkey.charCodeAt(i).toString(16);<br />
}<br />
}
This is what i got so far
private string ASCII_KEY, HEX_KEY;<br />
private char[] charArray = new char [95] { <br />
' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')','*', '+', ',', '-', '.', '/', <br />
'0', '1', '2', '3', '4', '5', '6', '7','8', '9', ':', ';', '<', '=', '>', '?', <br />
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', <br />
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', <br />
'\'', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', <br />
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'};<br />
<br />
private void GenerateWEPKey(int KeyLength) {
for (int i = 0; i < KeyLength; i++) {<br />
ASCII_KEY += charArray[GenPseudoNo()];
}<br />
for (int i = 0; i < ASCII_KEY.Length; i++) {<br />
HEX_KEY += charCodeAt(ASCII_KEY,i);
}<br />
MessageBox.Show(HEX_KEY);<br />
}<br />
<br />
private int GenPseudoNo() {<br />
Random rdm = new Random();
return (int)Math.Floor(rdm.NextDouble() * charArray.Length);
}<br />
<br />
private string charCodeAt(string ASCII, int index) {<br />
System.Text.ASCIIEncoding AE = new System.Text.ASCIIEncoding ( );<br />
byte [ ] alphabetArray = AE.GetBytes ( ASCII );<br />
System.Text.StringBuilder sb = new System.Text.StringBuilder();<br />
<br />
for ( int x = 0; x <= alphabetArray.Length - 1; x++ ) {<br />
sb.Append ( string.Format ( "{0}", alphabetArray [ x ]));<br />
}<br />
return sb.ToString(index,2);<br />
}
|
|
|
|
|
I need to be able to run an application on a local pc that is behind a firewall and get the internet ip address for the computer. does anyone know how this can be done in .net?
|
|
|
|
|
|
If you want the IP address of the computer behind the firewall (and you're outside), then you must define your protocol such that the IP address is included in the TCP (or UDP) message - not in the header (which is masked using the firewall's IP address with a NAT'd firewall). It probably won't do you much good, though, since 1) masked IP addresses are typically in the reserved range and don't route throughout the Internet, and 2) you still can't communicate with it directly.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
ok but, here's the thing i'm not outside i have a client app that runs on the client pc and i have a server app that needs the ip. the problem i had is that i need the client ip so i can route connection from the server to the client kind of like a one chat. the only restriction is i can't give out the server ip. so that leaves me with the only one option to have the server connect to client. so that's my situation.
|
|
|
|
|
Well, if you intend on actually connecting to a client behind a firewall, make sure you set up port forwarding for it.
As for getting the IP, your only choice is to use a machine outside the local network. Something like make a HTTP query to whatsmyip.com and extract the result.
|
|
|
|
|