|
jphuphilly wrote:
How do i get the text for a listview subitem?
tview.Items[x].SubItems[1].Text
listViewItem.SubItems[0].Text returns the text of the item,
listViewItem.SubItems[1] returns the first subitem, .Subitems[2] the second subitem, and so on.
|
|
|
|
|
Hi, there
Please help me with this. I try to show some message in a TextBox. Because it could be used by more than one threads, I lock ( this ) before I show the message. But it turns out, the 2nd thread can never get through "lock (this)". Could anyone please tell me why.
Thanks in advance.
public class LogClass <br />
{<br />
private TextBoxBase outputWin = null;<br />
public TextBoxBase OutputWindow <br />
{<br />
get <br />
{<br />
return outputWin;<br />
} <br />
}<br />
<br />
public LogClass(TextBoxBase win)<br />
{<br />
outputWin = win;<br />
}<br />
<br />
public void ShowMessage(string message)<br />
{<br />
string s = System.DateTime.Now.ToString() + ": " + message + "\r\n";<br />
lock ( this ) <br />
{<br />
if ( outputWin != null ) <br />
{<br />
if ( s.Length + outputWin.TextLength > outputWin.MaxLength ) <br />
{<br />
outputWin.Text = "";<br />
}<br />
outputWin.Text += s;<br />
}<br />
} }<br />
}<br />
}
|
|
|
|
|
In the object browser, the comments of a class or its member's summary and parameters can be displayed at the bottom of the window (these comments use "///"). When I compile the project to a .dll, reference this .dll into another solution, the comments of the classes in this .dll can't displayed in object browser. Why? How can I fix it?
|
|
|
|
|
You need to:
1) Turn on XML comments in the library project
2) Name the file the same thing as the dll (ie utility.xml for utility.dll)
If you do that, the IDE will find the comments.
|
|
|
|
|
|
I found that there is not a .xml document corresponds to .net library which involving .net classes. How does these library do that?
|
|
|
|
|
Can you give me an example
|
|
|
|
|
e.g. System.Windows.Forms.Button in system.windows.forms.dll
I have not found the corresponding file system.windows.forms.xml .
|
|
|
|
|
A custome control, which has a property "NormalImage", its type is Image.
When I use this control, In the Property Editor, once I have assign the property NoarmalImage a Bitmap, I can't set it to null anymore.
How can I set this property to be can-set-empty with attribute attached to this property?
The native control Button of .net framework has a property "Image", and it can be set to empty(null) through press the key "delete". How can I do like this?
Someone can answer me?
|
|
|
|
|
Dear, Sir
//If no the following line, press the key "Delete" will no result.
[DefaultValue(null)] //<====this line is important.
public Image Image
{
get {return yourImage; }
set {yourImage = value; }
}
I have a problem above this message. can you help me?
(see author: god4k).
;)
|
|
|
|
|
The DefaultValueAttribute( null ) is what the runtime checks
to see if the value is set to the default value. You also
need to set the yourImage to null in the ctor or where it is
declared. Also you need a method called ResetImage that
simply sets yourImage member to null.
Thank You
Bo Hunter
|
|
|
|
|
|
Hi Guys,
I have gone through ur code which is related with grid control in which combo box is used from the site codeproject.com
Actually the problem is that u have used custom control and on that u have created the grid. In the
Custom control u r giving one class name which is MFCGridCtrl and this class needs to be registered before the creation of the dialog box which is containing the grid.
For Registering u have used one function named RegisterWindowClass(). I have used the same function but I am not getting the custom control when I am executing the program. Can u provide some suggestion where I can correct the my code.
What I have done is as follows.
1) I have created one project which is dialog based and I have added custom control in it.
2) I have given the class name for the custom control.
3) I have added one class in the project and declaring its object in the main Dlg class. In the constructor of this class I am calling this RegisterWindowClass().
But when I am executing the program it is not showing me the custom control.
There is no error in the code. In the output I am getting only dialog box with the ok and cancel button.
Do provide the relevant information so that the custom control appears.
I am using MFC
I will be very thankful
If u need any information do let me know.
Regards,
Vimal Tomar
|
|
|
|
|
Vimal Tomar wrote:
I am using MFC
I suggest using your glasses too
leppie::AllocCPArticle("Zee blog"); Seen on my Campus BBS: Linux is free...coz no-one wants to pay for it.
|
|
|
|
|
I have a hashtable with the object property names as keys, and true/false bit as values. This hashtable represents a security schema. It sets access rights for every property of every object in my application. (I may change the true/false value to some combo of "rwz"..."read, write, or no access").
I want to apply this schema to my classes....I'm wondering if there is something flawed in the following design:
In the constructor, I will grab the the security schema and set the initial values of the properties to the values in the security hashtable.
When that object is instantiated from within a function, I will (usually) grab data from the database. If that particular property is already set to false (as the security hash directed), then I will not re-set the value from the database.
In the client code (ASP.NET pages), I haven't figured out yet how I will gracefully not show those values with the false setting...since they are false, they are not to be shown. If any of you know how to HIDE a column/field in datagrid/datalist/repeater based on property value, I would be much obliged!
Thank you for your opinions/suggestions.
|
|
|
|
|
but I can't see it!
I have a constructor
<br />
public nerd(int locNo)<br />
{<br />
location = locNo<br />
}<br />
and a method/function that uses that constructor
<br />
public nerd myMethod(int locNo, divNo)<br />
{<br />
<br />
nerd myNerd = new nerd(locNo);<br />
<br />
<br />
nerd.location = 9999;<br />
<br />
return nerd;<br />
}<br />
But the returned nerd object from myMethod shows its location property still equal to the original locNo, not 9999.
So I tried passing in a nerd object using the ref keyword, and got the same result.
What is going on here? Yes, the constructor set the value of location, but then I change that value so I should now see the new value, not the old. If I do this using a ref like so:
<br />
<br />
nerd myNerd = new nerd(6666);<br />
<br />
<br />
public nerd myMethod(ref nerd refNerd, int locNo, int divNo)<br />
{<br />
<br />
nerd.location = locNo;<br />
<br />
}<br />
<br />
myMethod(ref nerd, 9999, 1);<br />
<br />
I still get the old location number, not 9999.
Am I crazy?
|
|
|
|
|
sharkfish wrote:
public nerd myMethod(int locNo, divNo)
{
nerd myNerd = new nerd(locNo);
//but here I want to change the value of nerd's location property
nerd.location = 9999;
return nerd;
}
This is obviously not your actual code, as it would fail to compile unless location is a static property. If it is, that's where your problem lies, if it's not, consider posting your actual code, so the actual error can be spotted and pointed out to you.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Thanks for your reply.
I found my error.
It was something unrelated to the issue I posted.
Apologies for wasting your time.
|
|
|
|
|
I think you should specify this in your myMethod:
myNerd.location = 9999;
return myNerd;
instead of
nerd.location = 9999;
return nerd;
(which will not work unless it is a static class)
|
|
|
|
|
Hmm I'm not sure if this would be right or not (since I'm kind of new to C# myself ) but in your first listing of code shouldn't you use the object and change the location value wrt that object? I mean rather than doing:
nerd.location = 9999; // your code
shouldn't you do:
myNerd.location = 9999; ? // where myNerd is your object
And as for your constructor I think it should be like:
public nerd(int locNo)
{
this.location = locNo; // using 'this'
}
where the 'this' would point to your current object thereby changing that particular object's location...
Good luck as such...
|
|
|
|
|
Hi,
I've written this windows service in C# which unfortunately has a memory leak in it. Basically the program starts out using a 10Mb working set, but after three days it goes up to 200Mb, which says to me somewhere I'm forgetting to dereference some objects etc. The thing is I've looked and I can't find it.
Is there a tool or methodology for finding object references that are being held onto erroneously by my application? Shouldn't be too hard to find - theres 200Mb of them (and thats after 3 days - this thing is supposed to run 24x7)
TIA,
Andy
|
|
|
|
|
make sure you "Dispose" all objects which can be disposed!
setting the references to null wont nessaccarily kill the objects, the garbage collection in .NET removes dead objects periodically (from what I have seen)
Typically i have seen my applications the memory useage gradually goes up then every so often it returns to a normal level, this is probably when garbage collection kicks in.
I follow these rules:
1) Any objects which need to be closed get closed in a finally block
2) Any objects which need to be Disposed get disposed and set to null
Cheers, James
James Simpson
Web Developer
imebgo@hotmail.com
|
|
|
|
|
Search for "Application Profiler" on http://www.gotdotnet.com/community/usersamples/.
It'll enable you to see what's going on with your managed heap. There are other similar tools out there; try googling for "managed heap profiler" or similar.
Cheers, Julian
Program Manager, C#
This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|
|
|
I see that the word "defererenced" has taken on a whole new meaning in C#! This is very funny!
|
|
|
|
|