|
You will need to apply the same attributes that I posted above to EVERY property etc that you want to hide. There is no shortcut I'm afraid. The System.Windows.Forms.Control class is where most of the stuff you're seeing that you don't want comes from. That in turn derives from all of these:
Component, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable
If you derive from Component instead, you don't get any of the other stuff, but you then don't have a visible control. To make it visible as a control you'd need to implement IWin32Window [Edit] I think [/Edit]. I've no idea how to do that - I'm sure it is not trivial. If you decide to try, and figure it out, please write an article about it because I'd love to learn!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
modified on Monday, July 27, 2009 10:38 AM
|
|
|
|
|
Dave, your answer to this question was great...
I was just thinking about something to make this more useful..
if Class A inherits from Windows.Forms.PictureBox or whatever component and I need the Picturebox width and image to be used in my instances of A (MyA Object) how can i hide it?! I don't want to overload the inherited property. Also I couldn't use Shadowing!!!
how can i use some of inherited properties but hide them in propertyGrid...!?
Cheers,
|
|
|
|
|
If you remove the Obselete attribute, and in the getter/setter use the base values like I did, then you can continue to use the properties - they will just not be visible to the property grid or intellisense.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
I tried it..! I really don't know how to use it
do you have any sample for ObsoleteAttribute? I googles it but no useful samples found
|
|
|
|
|
MSDN[^]
It's pretty simple really.
Browsable(false) hides the property form the grid.
EditorBrowsable(EditorBrowsableState.Never) hides the property from the code editor.
Obsolete("xxx") makes the compiler generate a warning if there is an attempt to use the property.
Obsolete("xxx", true) makes the compiler generate an error (stops compilation) if there is an attempt to use the property.
You can create a new property and use it to get/set a different property (hidden or base class etc). Here is a code example - again in C#, but if you compare the code I provided previously, you should be able to translate.
public class MyPictureBox : PictureBox
{
[Browsable(false),
EditorBrowsable(EditorBrowsableState.Never),
Obsolete("This property is obselete", true)]
public new int Width
{
get { return base.Width; }
set { base.Width = value; }
}
[Browsable(false),
EditorBrowsable(EditorBrowsableState.Never),
Obsolete("This property is obselete")]
public new int Height
{
get { return base.Height; }
set { base.Height = value; }
}
public int MyWidth
{
get { return base.Width; }
set { base.Width = value; }
}
public int MyHeight
{
get { return Height; }
set { Height = value; }
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
There is not any thing like "base" in VB
I reckon I have to start my application in C#, this bloody VB does not have the flexibility of C#. I have to migrate to C# and it is really hard....
|
|
|
|
|
Hamid Amrabadi wrote: There is not any thing like "base" in VB
Well, that might come as a surprise to the inventors of the language since they included the MyBase keyword to cover this.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
As Pete said, MyBase will do it.
Learning C# isn't so hard. Inspite of all the hype, VB.NET and C# are very similar, mostly just syntax differences as you can see by comparing my VB example previously with the C# one. Once you get used to it, you may wonder how you ever managed to cope with VB
If you want to try, just have a go!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Another option you might want to consider is writing a class that implements ICustomTypeDescriptor.
Normally, a property grid fetches a type descriptor that (no surprise here) describes the type. You can create custom descriptors that alter behaviors; change editors on the fly, hide properties, show additional 'pseudo' properties, etc...
ICustomTypeDescriptor is implemented by a few classes, you might want to check the MSDN pages for more info on how to use this, if you're clever it will be much easier than rewriting classes with New properties and different attributes.
|
|
|
|
|
I have a c# .net 2.0 application that I created. What I need to know is how do I create a true
".exe" embedable code. I have a gizmo that I want to program. I must confess that I am beyond
my realm with this but thats how we learn. I understand how the .net framework works and how it
passes the assemblys to the "JIT" and the JIT the converts it to true machine code that the processer executes. do other platforms like borland create true ".exe's"? Or do I need to learn
Assembly language? I hope not as I am getting good with C# It is pretty straight forward. Maybe there is a compiler that will do what I need.
Thanks in advance.
Regards
Rick Osburn
p.s.
I am famillar with windows ce but I dont want to mess with the licensing fees just want to burn
it into a Eprom.
|
|
|
|
|
You can post your questions only one time!!!
BTW, if you want to develop an embedded system, there are specific dedicated ide's available for the same! Qnx MOmentics, Carbide etc etc....
.Net codes are executed only through .net framework!@!! So creating a standalone exe is merely impossible with .net@!!!
And you need not learn assebly language, whereas you can program with c or c++ libraries which will be converted automatically to corresponding assembly codes by the compilers!
Have a Happy Coding.....
|
|
|
|
|
I have Dictionary that contain (key values)
I want to display it in Grid in WPF in one row only
I mean : make the key as Column name and the related value the field value
so how can i do that I think I need to Build Dynamic Class
by Reflection and convert the key value of the dictionary to Properties
after that initialize an object and fill its properties with values from
dictionary after that bind the object to the Grid .
is that right or is there any easier way ??
You have To Search About The Truth Of Your Life
Why Are you Here In Life ?
|
|
|
|
|
Hi,
I want to show a tooltip.
How to show a tooltip in Win Ce?
what a class and namespace is for it?
Or i must use a API function? what?
Thanks
|
|
|
|
|
Hi,
I did some tests and realized that multicast delegates are slower than a generic list of delegates.
Did i make a mistake or is this correct?
This is the code i used.
class MyObject {
const int childMax = 10;
const int runMax = 100000000;
Stopwatch SW = new Stopwatch();
event EventHandler MyEvent;
List<EventHandler> eventList = new List<EventHandler>();
Dictionary<string, EventHandler> eventDict = new Dictionary<string, EventHandler>();
int iterator = 0;
public MyObject() {
for (int i = 0; i< childMax ; i++ ) {
eventList.Add(MyFunc);
eventDict.Add(i.ToString(),MyFunc);
MyEvent += MyFunc;
}
}
public void Test() {
SW.Start();
for (int i = 0; i< runMax ; i++ ) {
MyEvent(null,null);
}
SW.Stop();
Console.WriteLine("Iterator=" + iterator.ToString("n") + " using Events, Elapsed: " + SW.Elapsed.ToString());
SW.Reset();
SW.Start();
for (int i = 0; i< runMax ; i++ ) {
for (int j = 0; j < childMax; j++) {
eventList[j](null,null);
}
}
SW.Stop();
Console.WriteLine("Iterator=" + iterator.ToString("n") + " using List, Elapsed: " + SW.Elapsed.ToString());
SW.Reset();
}
private void MyFunc(object sender, EventArgs e) {
iterator++;
}
}
This is the result on my machine (2,2 gHz)
Iterator=1.000.000.000,00 using Events, Elapsed: 00:00:06.2153030
Iterator=2.000.000.000,00 using List, Elapsed: 00:00:04.8695574
Press any key to continue . . .
|
|
|
|
|
Not much of an actual difference. Just bear it in mind and don't use an event when you don't need to.
"Use the right tool for the right job." -- Scotty, et al
|
|
|
|
|
Hi,
running same code on a slower CPU (Intel Atom N270) I get the opposite result:
100M iter: events=3.9s list=5.1s
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
That's 14ns, yes nano seconds, difference per iteration.
I can't think of a real world situation that I've come across where that would be significant. I've certainly never had 100 million subscribers to an event!
Performance differences like this often exist but results can vary dramatically depending on other parameters such as hardware etc, and normally it is of no consequence anyway.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Why Dave, there are over 6 million CPians reading your daily messages, plus an unknown number of anonymous people, aka non-members; you may not consider them subscribers but they are real. Don't put them down.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I know CP has that many members, but it's only you saying that, that I've suddenly realised millions of people may read what I post... scary! Quite a resposibility really
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hello all,
I have this nagging error which i have applied common knowledge to solve it but could not. in the code segment below, I want to be able to loop through a dataset to extract value, but i keep getting the error as metioned "object reference not set to an instance......". as u can c, the objects i used are instantiated, please can anyone help solve this problem?
Dim dset1 As DataSet
Dim dt As DataTable
dSet1 = New DataSet
'The adapter stores the data in a dataset
dAdapt1.Fill(dSet1, "Patient Profile")
dt = New DataTable
dt = dSet1.Tables("Patient_Profile")
For Each rw As DataRow In dt.Rows --> Error Object reference not set to an instance of an object.
decdata = New TripleDES()
deRecDataFnam = decdata.Decrypt(rw("FirstName"), ned)
listItem = New ListViewItem()
listItem.SubItems.Add(deRecDataFnam)
ListVwPatProf.Items.Add(listItem)
Next
Thanks a lot!
|
|
|
|
|
ChiSmile wrote:
dt = New DataTable
dt = dSet1.Tables("Patient_Profile")
Yes, you're indeed initializing dt , but then you're reassigning it the value of dSet1.Tables("Patient_Profile") . Make sure you actually have a table in dSet1 called Patient_Profile .
Adam Maras | Software Developer
Microsoft Certified Professional Developer
|
|
|
|
|
ChiSmile wrote: dAdapt1.Fill(dSet1, "Patient Profile")
ChiSmile wrote: dt = dSet1.Tables("Patient_Profile")
Do you see the problem there? Here's a hint - you've got a magic string issue - when you use a string in one place to name something, you've got to use the same name whenever you refer to it.
Now, here's a piece of advice - learn how to debug. If you had set a breakpoint and stepped over your code (pausing to explore the values as you were debugging), you'd have found this issue straightaway.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
thank pete and Adams for ur help,it now works!.
Pete ur advice:
Now, here's a piece of advice - learn how to debug. If you had set a breakpoint and stepped over your code (pausing to explore the values as you were debugging), you'd have found this issue straightaway.
this is noted, but dont know how to do that. not that experieced though, will be glad if u show me. Thanks!
|
|
|
|
|
Put a breakpoint on dAdapt1.Fill(dSet1, "Patient Profile"). Run your code in debug mode and it will stop at this point - to "step over" the code (this means to execute your code a line at a time), press F10. If you want to step into a function, press F11 - if you have the pdb file, or the actual source.
To view the contents, you can view it in the locals window, add a quick watch, use one of the debugger visualizers or any one of a dozen other methods.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm working with a datagridview in Visual C# and one of the properties of this control keeps getting reset whenever I edit the GUI.
The following line appears in the source code:
//
this.dataGridView1.AutoGenerateColumns = false;
//
I want this property to be true however if I manually change it in the source it gets changed back to false whenever I edit the GUI. I didn't see this property listed in the properties box for the DataGridView control so I can't figure out how to permanently modify this value. Can anyone let me know where I should be looking?
Thanks in advance.
|
|
|
|