|
djkno3 wrote:
public int property
{
set {property = value;} //This throws the exeption
}
You're assigning the value to the property itself which is wrong.
You'll need a member varible of type int, so change the code to this:
public int MyPropertyName
{
set{ myMemberInt = value; }
}
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Thanks that was the problem. To get the value do I use the same variable eg return myMemberInt? It works like this but is it the correct way?
|
|
|
|
|
To create the read/write property you want, you will want to create a get:
<br />
public int MyPropertyName<br />
{ <br />
set{ myMemberInt = value; }<br />
get{ return myMemberInt; }<br />
}<br />
RabidK
|
|
|
|
|
thanks that's what I have I was just wondering if it was correct or if I was just getting the right answer by chance and have a nice bug pop up later because of it. thanks
|
|
|
|
|
It looks like the value entered in the TextBox is too big for an Int32.
MDSN:
The Int32 value type represents signed integers with values ranging from negative 2,147,483,648 through positive 2,147,483,647.
Pyt
Pyt.
|
|
|
|
|
I guess I should have said that the value was less then the max for an int 32 (eg It was 32) sorry
|
|
|
|
|
i have developed an application in dot net and i want to get its class diagram is there any facility available for that purpose in visual studio dot net ?
|
|
|
|
|
I thought, but I could be wrong, that VS .Net came with some version of Visio that would let you do this.
|
|
|
|
|
If you have the Architect version then you should find a copy of Visio on the installation media. It isn't installed by default. When installed there is an option to Reverse Engineer added to the Project menu.
Michael
Fat bottomed girls
You make the rockin' world go round -- Queen
|
|
|
|
|
There is an add-in project here on CodeProject that might be useful to you if you don't have a copy of VSNET Ent Arch and Visio for Ent Arch.
It's called PocketUML and from what I have seen, it does a pretty fair job:
http://www.codeproject.com/macro/pocketuml.asp[^]
I've downloaded it, but don't really use it much because I have the Ent Arch editions of both.
On a side note, does anyone know if Visio for Ent. Arch. supports full round-trip engineering? Or team collaboration?
RabidK
|
|
|
|
|
Hi all,
Since I have seen some of the greatest C# code on this site; I'd sure appreciate your contribution to a presentation I will be delivering. I'm looking for radical cool C# tips & tricks to demo. You will be mentioned in my presentation, if you do not object. So any cool stuff with unsafe code; com interop; or even general .Net cool tricks are welcome.
You (already) have my eternal gratitude.
Rudi
|
|
|
|
|
I've given this type of talk a bunch of times since .NET came out and it really depends on the type of audience.
If you use instant messenger then we can chat: simon_stewartDEFINITELYNOTFORSPAM@hotmail.com -- removing capital words.
Cheers,
Simon
"From now on, if rogue states want to buy weapons of mass destruction, they're going to have to go on eBay," Mr. Bezos said.
|
|
|
|
|
I have finally found a good use for looping in a small tool I am creating.
maxBits: is defined elsewhere in the code as a maximum integer that cannot be passed.
subs: is also defined elsewhere as an integer that needs to be passed by at least a value of 2.
---------------------------------------
A little more in depth:
IE- (2^x), where "x" is an integer value.
What this is really trying to find is the "x" power of 2's value, that is right after the value of "subs" but that power cannot be higher than "maxBits" and if it is, it is invalid and a message needs to be passed to the user.
Here is my code:
------------------------------------
// newSubs is the value of the "x" power of 2 right after the value of "subs" int newSubs = 0; int n = 0; for (int i = 0; i <= maxBits; i++) {
while (n < subs)
{
newSubs = 2^i;
n = tSubs;
}
}
------------------------------------
It just isn't working and I don’t know why. I have tried many different cominations of looping structures to get the effect I need. With the code given above, the program crashes when a value of 3 is assigned to "subs".
Can anyone help me with the looping structure? I am going insane just thinking about it
Thanks for the help.
Regards,
********************
* SteveMcLenithan
* <a href="mailto:steve@steve-mac.com">steve@steve-mac.com</a>
* <a href="http://steve-mac.com">http://steve-mac.com</a>
********************
|
|
|
|
|
looks like my code didnt paste right the first time. hopefully it will work now...
// newSubs is the value of the "x" power of 2 right after the value of "subs"
int newSubs = 0;
int n = 0;
for (int i = 0; i <= maxBits; i++)
{
while (n < subs)
{
newSubs = 2^i;
n = tSubs;
}
}
********************
* SteveMcLenithan
* steve@steve-mac.com
* http://steve-mac.com
********************
|
|
|
|
|
Well, in C# the '^' operator is the XOR operator. To accomplish what you need you can:
1. Use Math.Pow method
2. If you need 2x you can always use 1 << x , which will operate only in integral types (byte, short, int and long) and is super fast.
I see dumb people
|
|
|
|
|
I have a richtextbox where things will be printed in it from other textbox's. But when the richtextbox is filled with text, instead of the scrollbar automatically scrolling down as new text is appended to the richtextbox, the scrollbar stays at the top and the new text can't be seen unless the person moves the scrollbar himself. Is there a property which allows me to change the location of the scrollbar so that the scrollbar automatically moves down as new text is appended to the richtextbox?
Thanks
|
|
|
|
|
|
Thanks, it works fine except for now when I hit enter in the richtextbox, it will make a new line. I can't input any other letter or anything, enter is the only thing that changes richtextbox... I'm sure I'll figure out how to stop it sooner or later, but do you know why it does this?
|
|
|
|
|
i have a c# program where i run perfectly no problem under win2000.
however, the problem occur when i try to run in win98 installed with
.NET Framework 1.0.3705.
(1)i try to hide the main form and display the system tray icon when
user click on minimize button. i put the following code in main form
constructor:
------------------------------------------------------------
this.Resize += new System.EventHandler(this.frmMain_Resize);
this.notifyIcon1.DoubleClick += new
System.EventHandler(this.notifyIcon1_Click);
------------------------------------------------------------
the function of frmMain_Resize look like:
-----------------------------------------
private void frmMain_Resize(object sender, System.EventArgs e)
{
if( this.WindowState == FormWindowState.Minimized )
this.Visible = false;
}
-----------------------------------------
the function of notifyIcon1_Click look like:
-----------------------------------------
private void notifyIcon1_Click(object sender, System.EventArgs e)
{
this.Show();
this.WindowState = FormWindowState.Normal;
this.Activate();
}
-----------------------------------------
when i click minimize button of the main form, main form hide and the
system tray icon display. i double click the system tray icon and the
main form show up again. then when i click on minimize button again,
nothing happen.
i realize the frmMain_Resize wont be execute. this problem only happen
when i run this application in win98. win2000 work perfectly.
(2) please refer http://www.geocities.com/yccheok/net/prob.html for
screen shoot.
i try to display a modeless dialog with code
--------------------------------------------
if(frmViewLive.IsDisposed)
{
frmViewLive = new FrmViewLive(this);
this.AddOwnedForm(frmViewLive);
frmViewLive.Show();
frmViewLive.Activate();
}
else
{
this.AddOwnedForm(frmViewLive);
frmViewLive.Show();
frmViewLive.Activate();
}
--------------------------------------------
although i click on the close button of the frmViewLive, the task bar
still displayed its "Live Image" title. when only i click on the "Live
Image" task bar, only will the task bar disappear. this is strange coz
win2000 has no this kind of problem.
may i noe how can i solve this problem? thank you.
regards
yccheok
|
|
|
|
|
1) The message you want to catch is not normally exposed by .Net. Clicking on the minimize button, or by using shortcut keys, etc., sends a WM_SYSCOMMAND message to the form's window, along with a command value of SC_MINIMIZE. There is a way to capture these messages, however, so you can really polish your app.
In your app's constructor, add:
this.SetStyle(ControlStyles.EnableNotifyMessage, true);
That will allow you to override the OnNotifyMessage() function, which catches all window messages. So add to your app's methods:
protected override void OnNotifyMessage(Message msg) {<br />
<br />
if (msg.Msg == 0x0112 &&
(uint)msg.WParam == 0xF020) {
<br />
MessageBox.Show("Minimize activated");<br />
}<br />
}
I'm fairly sure that no matter what platform you run on, the message box will fire on any minimise event. That includes minimising from the taskbar, or any other means. Of course, you'll want to replace the message box with your form-hiding code. No other event will falsely trigger minimising either.
Cheers
|
|
|
|
|
thanks n i will try it out 2night. but can u tell me why
this.Resize += new System.EventHandler(this.frmMain_Resize);
won't work in win98?
thank you.
regards
yccheok
|
|
|
|
|
yccheok wrote:
won't work in win98?
You can't run .NET applications on Windows 98.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Nick Parker wrote:
You can't run .NET applications on Windows 98.
Sure you can, its Windows 95 that isn't supported
James
- out of order -
|
|
|
|
|
James T. Johnson wrote:
Sure you can, its Windows 95 that isn't supported
Oooppps, I was thinking of the .NET Framework SDK requirements.[^]. Thanks James, I think it time for me to go to bed now.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Honestly, I'm not sure, although I do know that there were some changes in message handling, that started with W2K. I was only thinking in terms of giving you a better solution to your problem, and had not looked into the cause of your difficulties.
A simple way to find out, would be to temporarily add logging to app (or add a textbox), and list every message received in your new handler. Then just compare the list of events triggered after clicking the minimise button in W98 and W2K. You could do the same thing with Spy++ too.
One of the frustrations I have with .Net, is that I can't see how things work like is possible with MFC/ATL/WTL. So the answers aren't always obvious.
Cheers
|
|
|
|