|
moredip wrote:
I don't think I am using instance-specific data, only class-specific.
Inheritance is just not an option then...
What you want to design is numerous singleton classes each doing it own thing, BUT you want all the benefits of inheritance (which we have said will not work).
moredip wrote:
All you need for a Delete is a tableName and a PKName, right? And that isn't instance specific, it's class-specific.
Place that function in a util class as a static method then passing the tablename and pk value.
moredip wrote:
So I don't see why C# won't let me create a base class static function Delete() which uses a different value for a static variable depending on what the instantiating class is.
Youre contradicting yourself here. placing static and instance in the same sentence is unsafe . Just think about it, if you have a static function say Class.Delete() , what is it suppose to delete??? I assume these classes are mapped to a table or a record. What happens if you have 2 records open at the same time, which one is meant to get deleted?
moredip wrote:
When you say "you want to use a single value to store 3 different values. That is just impossible" I disagree. If you think about it, it's no different than using one method signature to refer to 3 different methods depending on the invoking object's class. The difference is that it's a string rather than a function pointer, and that the polymorphism can be resolved at compile-time, not run-time (I think...).
OK I should have rather said, pointing all to one address then. Strings are infact stored as pointers.
moredip wrote:
Hmm, I think this could all be academic anyway, if C# can't do it then it can't do it. It just seems ugly to me to create a non-static variable that doesn't use any instance-specific data.
Then you will have to boot an OO approach and follow the C approach using C style parameterized functions. Which will probably much easier doin git in C/C++. Did you look at my code though (i didnt mean copy)? I run into similar issues, hence using an instance design. No I have no problem if you create classes for a Table as well , but that would be unnecesary using an instance approach. These table classes would have a static Delete fucntion, but would need at least need one parameter but you would lose inheritance thus losing the abilty to cast and use base classes's methods. And interfaces.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I don't think I'm explaining myself very well here
I see what you're saying about having util classes with static methods, rather than inheritance, but I like the idea of having both in the same class. It means only specifying things like tableName and PKName once (rather than once in the instance-base class and once in the util class). And as these are stored in the class, one can use polymorphism to delete a row from a table (for example) without having to know what kind of table it is.
Unfortunately, it seems that we're both agreed that this just isn't possible in C#. So i've make the relevant variable readonly properties that always return the same value, e.g.:
class DBData
{
virtual protected string tableName{ get{ return ""; } };
....
....
}
class AuthorData : DBData
{
override protected string tableName{ get{ return "Author"; } }
....
....
}
Now I can write functions like Delete( uint rowID ) in the base class, and via polymorphism they DELETE from different tables depending on what the type the instantiating class is.
This seems less clean to me than using static functions, but it does the job.
RE: placing static and instance in the same sentence, you're quite right. I was using the wrong terminology there. What I meant when i referred to the instantiating class was the class used to call the static method: e.g. with ChildA.SomeMethod() ChildA would be the instantiating class, even though the method is only declared in the base class. Do you see what I mean that with static inheritance polymorphism (which I think could just be a fancy way of saying genericity), the method would behave differently depending on what class was used to call it. E.g. ChildA.SomeStaticMethod() would have different results to ChildB.SomeStaticMethod(), even if neither redefined the method, but simply redefined so static variables.
Oh, and you're right about the static Delete function not making sense. I meant to say that it would be Delete( uint rowID ), where you specify the row you want to delete as a parameter. It seems a bit silly to me to instantiate an entire object just so you can set its rowID and then delete it
I hope I've cleared that up a bit. Sorry, I'm terrible at expressing my ideas on 'paper'!
I'm still working on a solution to this using readonly properties - and I might have to dirty my hands a little with Reflection (not sure yet). If you'd like I can send you my code so you can get some idea what I'm working towards.
|
|
|
|
|
moredip wrote:
Now I can write functions like Delete( uint rowID ) in the base class, and via polymorphism they DELETE from different tables depending on what the type the instantiating class is.
This seems less clean to me than using static functions, but it does the job.
Please look how I did it in my code. I just a nice inherited Delete() function without any parameters. Look at the base class in the Interfaces.cs file (ok the filename is a bit dumb).
To do what you wanna do, will force you to rewrite the each fucntion (i have gone over this).
Best is to think about your whole design again. What you will designing if you succeed, will be some classes that cannot be reused in any way, destroying the concept of OOP. I ussually have to redesign a class structure 4/5 times to make it work in its most effecient way. So just go and sleep on the thoughts for the next few days.
You can mail me your code, I could have a look at the design, maybe some mistunderstandings will be cleared up.
moredip wrote:
I hope I've cleared that up a bit. Sorry, I'm terrible at expressing my ideas on 'paper'!
Same here
moredip wrote:
I'm still working on a solution to this using readonly properties - and I might have to dirty my hands a little with Reflection (not sure yet). If you'd like I can send you my code so you can get some idea what I'm working towards.
Now I really dont want to know what you are trying todo with readonly properties.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hi all
I have bound a textbox to a field in a table. The problem is however that databinding does not occur until either control gets destroyed or it text is changed by moving to the next element. Now when I want to save the dataset to xml, I have to move to another element, before the changes are reflected.
How can I manually force databinding on a textbox?
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
OK found answer, before the page even reloaded
control.DataBindings[0].BindingManagerBase.EndCurrentEdit();
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
I have one treeview and one toolbar in my form.The toolbar has TOP DOCKING and I want TreeView has Left Docking.When I set the its docking it takes all of the left side of the form,and the form set the TOP DOCKING of toolbar at the second,so it does not take all of the top of the form and it start after hte TreeView,how can I change this,so Toolbar takes all space at the TOP,and TreeView start below it with Left DOCKING?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Make sure the toolbar is added to the forms control collection before adding the treeview.
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Hehehe..
Well,I had to add TreeView BEFORE toolbar,but anyway now its right.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Mazdak wrote:
I had to add TreeView BEFORE toolbar
Now that is so dumb (not you, but M$)
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
hehe , ms didnt do anything wrong..
r-click one of the controls and choose send to back or bring to front and see what happends
//Roger
|
|
|
|
|
ja ja It's my way or the highway
I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02
|
|
|
|
|
Its not the correct way.With this will it will come to front,but it will cover another control.It is not the solution for my problem.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
i am finding something like CWinThread in C# to Create multi UI Thread.Can anybody help me?Thanks!!! sdfasdfasdf
|
|
|
|
|
Would you please delete your extrs messages?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
i am finding something like CWinThread in C# to Create multi UI Thread.Can anybody help me?Thanks!!!
|
|
|
|
|
Could you not post it 4 different times?
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
i am finding something like MFC's CWinThread class in C#,i need creat muitl UI Thread.Does anybody kown and can tell me?think you every much!
think you every much!
|
|
|
|
|
i am finding something like MFC's CWinThread class in C#,i need creat muitl UI Thread.Does anybody kown and can tell me?think you every much!
|
|
|
|
|
Have you tried using the System.Threading namespace and the System.Threading.Thread class? I believe those will give you what you want.
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
We had HTMLView in MFC,so we could browse web or HTML page in a view in a application(I think it refers to IWebBrowser ).Now do we have something like that in C#?I want my application show HTML or ASP pages inside itself,not open with IE.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Mazdak wrote:
We had HTMLView in MFC
I hope you don't think the MFC CHTMLView provides a full fledge rendering engine by itself. CHTMLView is only a IE wrapper, just like the IE wrapper you get by dropping the Web browser control onto a Windows Form.
Mazdak wrote:
I want my application show HTML or ASP pages inside itself
I don't know if that's me, but that means pretty much nothing. Last month, ASP was still a server-side scripting engine providing facilities to build web pages that, once built, are sent to the client browser.
|
|
|
|
|
.S.Rod. wrote:
CHTMLView is only a IE wrapper, just like the IE wrapper you get by dropping the Web browser control onto a Windows Form.
Yes,that works. Thanks. But I have a problem with it.When I click a link inside the control it open a IE and want to browse it in new window.Do you if I can prevent it?
.S.Rod. wrote:
I don't know if that's me, but that means pretty much nothing. Last month, ASP was still a server-side scripting engine providing facilities to build web pages that, once built, are sent to the client browser.
Yes,you are right,I know it.I didn't want to browse ASP page in my application.It was just a mistake,I was typing quickliy and didn'r mention it.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Mazdak wrote:
Do you if I can prevent it?
Yes. Override OnNewWindow2 and OnBeforeNavigate2 and make sure to assign true to the cancel arg : e.Cancel=true, where e is the event handler arguments. This article[^] also shows how to properly handle new windows : in fact, you can create a new Form instance at such moment and create a new browser control instance there, so it behaves right.
|
|
|
|
|
Thanks.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
I just downloaded the 65MB C# Direct X SDK (quite a lot for a 56k), installed it, rebooted, fired up VS.NET ann.....
None of the Direct X references were there. I have the DX Redist Runtime and .NET framework installed. Do I need to download the huge 'full' SDK just for some dlls?
I don't see how a few samples and some XML files can cause a 65MB download without providing the core files needed to develop.
"How long has the "Quote Selected Text" been around???" - Marc Clifton, Lounge 4 Mar '03 "But a fresh install - it's like having clean sheets" - Chris Maunder Lounge 3 Mar '03
|
|
|
|