|
hi..if you have some free time, i'd appreciate if you can please help me.
please consider the following code :
class sample<br />
{<br />
protected int i ;<br />
public sample( )<br />
{<br />
i = 10 ;<br />
}<br />
}<br />
class sample1 : sample<br />
{<br />
public sample1( )<br />
{<br />
Console.Write ("Hello " + i ) ;<br />
}<br />
}<br />
class Class1<br />
{<br />
static void Main ( string[ ] args )<br />
{<br />
sample1 s = new sample1( ) ;<br />
}<br />
}
which yeilds the result : Hello 10
my prob : AS I CAN UNDERSTAND : in above case the derieved class is accessing the protected attribute of the base class... but i thought in CS that wasn't supposed to happen..
OR am i looking at it wrongly??
pls help..tks a lot
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Open Visual Studio, open the Help menu, select "Index".
Look up "protected keyword" and you will get the full explanation.
|
|
|
|
|
any more explanation??
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
What did you find out about what "protected" means?
|
|
|
|
|
Joseph,
I think that the problem is that some of the folks on this forum may think that your questions are just a little too newbie-ish(?). For example, access modifiers like protected are covered very, very thoroughly in all beginner-level C# programming books, even the bad ones. Have you bought any books? You may also want to consider enrolling in a class somewhere to learn what object-oriented programming's all about. It's simple once you learn it, but learning it is not simple for all people. You won't learn OO programming by asking newbie questions on this forum, either.
So if you were to go off, learn the definition of protected , write some sample code to play around with it, and then you still had questions, it would be a different matter.
The answer to your question in this case is that you are confused on the difference between private and protected . private means that nothing outside of the class (not even child classes) can see the thing so labelled; protected means that only the class itself and child classes can see the thing so labelled. You could have easily found this out by browsing the MSDN help.
I'm not trying to put you down-- it's great that you're learning. Still, to flood this or any forum with questions you can easily answer for yourself amounts to a sort of spam. Also, like I said, I don't think that you will get what you're after this way; your goal should be a good understanding of these concepts.
Thank you.
Jeff Varszegi
|
|
|
|
|
al right!!!! got it!!
you see the problem was i read but in a haste..
when i read..
The protected keyword is a member access modifier. A protected member is accessible from within the class in which it is declared, and from within any class derived from the class that declared this member.
A protected member of a base class is accessible in a derived class only if the access takes place through the derived class type. For example, consider the following code segment:
i didnt understand how it was related to my question...
but then i tried to read it slowly and now i understand...
to protected..someting like Privatish also applies
thats why..
when its own class tries to access its own protected directly..it cannot..
cause its protected is privat(ish) too...
but to a derived class its not private and can access directly hence :
class A <br />
{<br />
protected int x = 123;<br />
}<br />
<br />
class B : A <br />
{<br />
void F() <br />
{<br />
A a = new A(); <br />
B b = new B(); <br />
a.x = 10;
b.x = 10;
}<br />
}<br />
i got it right???
P.S : tks for the advice Mr.Jeff..;)
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
"For God so loved the world that He gave His only begotten Son, that whoever believes in Him should not perish but have everlasting life."
John 3:16
"Therefore you also be ready, for the Son of Man is coming at an hour you do not expet."
Luke 12:40
|
|
|
|
|
Regards,
I have two important questions, I would be thankfull some buddy kindly replies me:
1. When starting a UserControl library project, code generated by VS.NET doesn't contain a constructor overload that gets an IContainer parameter so that the host form can add it to its 'components' property collection at instantiation time. why is that and in situation like this how these controls will be added to host's components collection? while we know any UserControl is a component too.
2. I wan't a complete example of how to implement a correct Dispose mathed when there are other components' instances in current class and this clas itself will be instantiated on other class, and after we call all nested components' Dispose method(), should we set their instances to null too?
Thanks
---
"Art happens when you least expect it"
|
|
|
|
|
Hi , i know i can enable xp themes on winforms gui in .net 1.1 with some command.
and i also know that i can enable themes if i include a manifest in .net 1.0 and 1.1.
but how can i enable themes for a control via code in 1.0??
NOTE: i dont want to DRAW the control myself , i just want to enable xp themes on scrollbars for a customcontrol via code
//Roger
|
|
|
|
|
You can't do it through code without drawing everything yourself in 1.0 - you can use a manifest file, however, either with the same filename as your app with ".manifest" appended, or as an embedded resource (Win32 resource, NOT .NET embedded resource). See my article at http://www.codeproject.com/csharp/dotnetvisualstyles.asp[^] for more information.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
so .net 1.1 uses black magic to enable the xp themes?
surely there must be some api call(s) to enable the styles..
//Roger
|
|
|
|
|
No, it doesn't use "black magic". The concept is simple and could be found by reading the docs for the Theme API. The manifest file (with appropriate sections) redirects any calls to a file (in this case, comctl32.dll) to a side-by-side assembly. .NET 1.1 requires that you do this before starting the application (Application.Run ) because it uses a manifest file called XPThemes.manifest (in the .NET 1.1 runtime directory) to accomplish the same thing.
This is the only way to do it in 1.0. If you don't believe me, MSDN has a couple articles outlining the same thing.
"Magic" is the art of misdirection. Theming is the art of redirection. It's all in the documentation for the Theme API.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I have an IntPtr variable, and I want to change area of memory on which he specifies? How can i do this?
Excuse my english.
|
|
|
|
|
Marshal.StructureToPtr(newContent, intPtr, true);
|
|
|
|
|
If anyone is interested, I have translated an existing example of skinned mesh to the summer release of the DirectX9 SDK and cleaned up the code so it hopefully is easier to understand. It is written in C# for VS 2003.
Download at:
http://bjoernen.ebolaget.com/directx/animatedmeshexample.zip
Feel free to comment or correct my code.
Regards, Björn.
|
|
|
|
|
hi.
I intrested but your link is broken.
can you send me project.
I realy need that.
sajjad_9k@yahoo.com
|
|
|
|
|
If you can help me with this one you are a champion. I havn't been able to find anyone that knows how to do this.
I need to loop through all embedded icons in an embedded folder and populate an imagelist. As seen below, I have an embedded folder Prud.Library.Icons.State which contains a set of icons. I would like to add all Icons in State to an ImageList regardless of their name.
Does anyone know how this can be done?
Thanks heaps.
Note: string sIconName = "Prud.Library.Icons.State.Icon1.ico";
System.IO.Stream objStream = null;
System.Drawing.Icon[] objIcon;
try
{
/*
* Stream Icon and add to ImageList
*/
objStream = this.GetType().Assembly.GetManifestResourceStream(sIconName);
if (objStream != null)
{
objIcon = new System.Drawing.Icon[1];
objIcon[0] = new Icon(objStream);
}
}
catch (Exception err)
{
throw err;
}
finally
{
/*
* Dispose of Stream Object
*/
if (objStream != null)
{
objStream.Flush();
objStream = null;
}
}
return objIcon;
|
|
|
|
|
ImageList images = new ImageList();
images.Size = new Size(16, 16);
Assembly asm = this.GetType().Assembly;
string names[] = asm.GetManifestResourceNames();
if (names == null) return images;
foreach (string name in names)
{
if (name.StartsWith("Prud.Library.Icons.State"))
{
int index = name.LastIndexOf(".");
if (string.Compare(name.Substring(index), "ico", true) == 0)
{
Stream s = null;
try
{
asm.GetManifestResourceStream(name);
Icon ico = new Icon(s);
images.Images.Add(ico);
}
finally
{
is (s != null) s.Close();
}
}
}
}
return images;
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Does anyone know how to stop a particular column within a datagrid from being resized?
Sounds simple enough but I have not been able to find anyone that knows.
Thanks for you help.
|
|
|
|
|
You can override the OnMouseMove and OnMouseDown methods and check if the user is trying to resize that specific column.
public class MyDataGrid:DataGrid
{
protected virtual bool CancelMouseAction(System.Windows.Forms.MouseEventArgs e)
{
System.Windows.Forms.DataGrid.HitTestInfo hitTest=this.HitTest(e.X,e.Y);
if(hitTest.Type == DataGrid.HitTestType.ColumnResize)
{
//lets say that you want to skip column 1
int skipColumn=1;
if(hitTest.Column==skipColumn){return true;}
}
return false;
}
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if(!((e.Button==MouseButtons.Left)&& CancelMouseAction(e))){base.OnMouseDown(e);}
}
protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
{
if(!CancelMouseAction(e)){base.OnMouseMove(e);}
}
}
ps. I don't have any idea why OnMouseMove appears like this...
Best Regards,
Daniel Zaharia
|
|
|
|
|
How DataSet can be used in Client Server Application?
In my Client Server Application I had MSDE as a Server Side Database.
It has multiple clients in the same network as multiple instances of a Windows based client side applications which directly connected to the server side database(MSDE). In the client side application, it has a data entry form. In which we can scroll through records(next previous etc.) and can insert , delete, update records. For this purpose I use a DataSet in C# and when the form loads the data is retrieved from database to the dataset and for inserting, I use NewRow() method of DataSet and after inserting called the Update() method of DataAdapter. for deleting Delete()method of DataSet. In a single machine it works fine, When using the same application from multiple machines in the same network, any changes made in one machine should not be affeced in the other machine until the form is closed and reopened, because the dataset is populated at the form load event. I want to track the changes without closing. What is the best way for doing that in this kind of application ?. Can anybody give me the detailed idea of client server database application using C#?
Thanks in advance.
Cenray
|
|
|
|
|
so you had a big problem ,
i dont know you application but you can provide the form with a button for refreshing the data and get the latest changes from the database
in the button you can use fill function from the data adapter
otherwise if you want to get the changes in the real time you have to de the foolowing :
1- create function with c++ to open a TCP socket then send a string on this soket
2- compile this function to support an extended stored procedure for sql server
3- goto the sql server then add a reference to the dll which contain the function you had created
4- create a trigger on the table you want to monitor it on add or update and call that function to send an alert to all users of your application
5- in the application side you have to open a TCP socket listner for geting the alerts from the database
then you can refresh the dataset as well as you had an alert from the database
so chose one of that solutions
|
|
|
|
|
I'm writting C# code with web project, I want delele network share file, and try it
File.Delete(host\folder\filename) but it error :
[b]Logon failed
bad username and password to logon[/b]
somebody can help me to solve it
thanks
Nho'c Ti`
|
|
|
|
|
befor any thing you should use the following path :
\\computer_name\Directory\file_name
if you use that path and the error still appear you should test you permission to sccess the target computer then try it again cuz this message mean's that you don't have access permission to that folder or file in the target computer
you can make simple test try to delete it from the windows explorer
|
|
|
|
|
I can delete it form window explorer or use application project , but with webproject I can't delete it.
Login Failed
please help me!
Nho'c Ti`
|
|
|
|
|
somebodys can help me do that?
web project: why i'm try delete it but occur an error "access denied" so that folder i had shared with full control for everyone
thanks!!!
Nho'c Ti`
|
|
|
|