|
I am interested in creating an application that is similar to a windows start bar which docks to the top of the desktop instead of the bottom. It is unclear to me how I would go about building such an application. I need it to interact with the icons on the desktop such that it just doesn't cover them over but moves the icons appropriately down to make way for the window that is docking to the top. Just as when you are resizing the windows start bar on the bottom the icons are rearranged to make room for the larger start bar.
If anyone could point me in the right direction as to what I am trying to do is called or give me a few hints. It would be greatly appreciated.
Thanks
|
|
|
|
|
|
After creating a new class that inherits the System.Windows.Forms.TextBox, in the new class I would like to set value of the default Name (other defaults as well) for the TextBox when a new instance is created by dragging the control from the Toolbox and dropping it on a Form. Any idea how to do this?
Kyle
|
|
|
|
|
simple override the constructor to set the values.
if you want it to play nice with the property browser ( making it look there hasn't been a change ), then either override the property declaration with a new DefaultValue attribute for simple types, or for complex types, override or create a new version of each ShouldSerialize<propertyname> method, and return false if it equals your value.
|
|
|
|
|
Andy,
Thank you very much for your help. Yes I do want to play nice with the property browser. Setting the value of properties in the constructor means they are now fixed at that value regardless of changes made in the property browser. I am looking to maintain normal design time behaviour. I just want to override the default name that appears when a control is dropped on a form. I tried to override the property declaration with this code:
private string name = "";
[DefaultValue("tbx")]
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
but got this warning:
c:\documents and settings\kyle\my documents\visual studio projects\numericonlytextbox\numericonlytextbox.cs(49,17): warning CS0108: The keyword new is required on 'CustomControl.NumericOnlyTextBox.Name' because it hides inherited member 'System.Windows.Forms.Control.Name'
and it did not set the Name value to the default "tbx".
I am also very intrigued by the ShouldSerialize method. Do you have any short segments of code you would share that could help me to better understand overriding the inherited property and SouldSerialize method?
Thanks again,
Kyle
|
|
|
|
|
kyledunn wrote:
Setting the value of properties in the constructor means they are now fixed at that value regardless of changes made in the property browser.
This is false. Setting values in the constructor will not do that. you need to set the value.
kyledunn wrote:
and it did not set the Name value to the default "tbx".
it didn't change it, because you never set it. the DefaultValue attribute is only for the IDE to know when it's been changed. It doesn't actually set the value. You have to set it yourself in the constructor.
kyledunn wrote:
but got this warning:
that warning is because you need to explicitly say whether it is an "override" or a "new". In this case, since the "Name" property is not virtual, you can only use "new".
All that said, it is a REALLY BAD IDEA to try to override the Name property. Controls do magic things with the name property to make sure they are unique. Making them all "tbx" would be a BAD THING.
|
|
|
|
|
Hi Andy,
I set the value of this.Width to equal 300 in the constructor for the custom textbox control and then changed it to 100 in the property browser. Upon running the form the textbox reverted to a width of 300 which led me to the false statement above. I just tried setting the value to any other number than it's original default and it worked as you described. The original default number was influencing the behavior I was describing.
Thanks for the explanation about the DefaultValue. That makes sense.
I agree it's a bad idea to change the default name. I was interested in changing the default, not necessarily getting rid of the sequential number, but it was a bad example to choose.
Thanks for your help.
Kyle
|
|
|
|
|
In moving over my code, I'm now to the MFC Wizards that we created.
We used to create a property page/sheet and call SetWizardMode to activate them, but alas, that feature is no longer in .NET
So, what is our replacement feature/procedure for this? I created a form, threw in a tab control, but could not find a way to hide the tabs.
Any thoughts?!
|
|
|
|
|
|
I read that one in my research and it really didn't tell me anything. Just a kludge work around.
But talking about kludges... I hid the tab controls under a panel and life is nice again. Kludgie, but nice.
I know there is a Wizard component available, but I really don't want to spend $160 just to hide a tab.
|
|
|
|
|
psdavis wrote:
I hid the tab controls under a panel and life is nice again. Kludgie, but nice.
Not bad. Did you set the tab position to bottom and added a panel with Next, Finish, Back etc. buttons?
|
|
|
|
|
Yep!
First off, changed the tab control to display tabs on the left.
Then, I added 4 panels total. One on top for the heading, one on bottom for the next/back, one on right for balance, and one on the left to cover up the tabs.
When I want to see the tabs, I send the left panel to back, when I want to hide them, I move the left panel to front.
Works pretty darn well.
|
|
|
|
|
Hi,
Does anyone know if there is a function in C# that will refresh a TreeView? I know this function existed in J++ but does it exist in C#? I want the jobs that get added to the node to be listed alphabetically without having to rebuild the tree again. If I quit the program and then reexecute it again -- they appear alphabetically.
If anyone knows how I might achieve this without having to rebuild my tree I certainly would appreciate. Thanks.
cAptHiDDeN
|
|
|
|
|
Just guessing...
MyTree.BeginUpdate( );
... (add nodes) ...
MyTree.EndUpdate( );
|
|
|
|
|
I'll tried that before -- close but no cigar. Anyone else know if this is a bug? It would certainly be nice if these were sorted. I am sure someone will figure it out eventually. Let's all hope so.
cAptHiDDeN
|
|
|
|
|
I am using the tree at this very moment and it refreshes just fine on it's own alphabetically. I think you must be creating the nodes wrong or something. Do you have the sorted property selected to true? It works just perfect though.
anyway peace
|
|
|
|
|
Damn...all that I had to do what change the sort property from false to true. I just hate it when its something that simple -- and you think it would be something more complicated. It would have been nice if J++ version 6.0 was this easy!!! hehehe
Thanks for the help.
cAptHiDDeN
|
|
|
|
|
Curious if anyone's heard when the next version (or service pack) of .NET/C# is due? And does anyone know of anything new that will be in it?
Thanks!
|
|
|
|
|
Hi all,
In Java swing, JTable lets users modify the content of each cell and different types of construct can be associated with each table cell, eg. a drop down list, string and so on. So it is extremely flexible.
Could anyone please tell me if there is similar class available on C#? I have searched the internet for a long time and couldn't find one. Is there any workaround to handle this situation?
very much appreciated.
Wilson
|
|
|
|
|
it's the DataGrid control.
|
|
|
|
|
I want to extend a control (MenuItem, to be specific). But I want Visual Studio's Windows Forms Designer to use my new control (call it MyMenuItem) instead of MenuItem when using the Designer to create a MainMenu.
How does one do this?
Thanks in advance!
Steve
------------------------------
steve@crozier.com
|
|
|
|
|
Unless the MainMenu designer has this feature in there already you'll have to create your own MainMenu type class and designer so that it creates MyMenuItem s instead of MenuItem s.
James
"Java is free - and worth every penny." - Christian Graus
|
|
|
|
|
I am porting some code from c to c# and the original code makes a lot of use of #define macros - is there an equivalent in c# - at the moment I am turning the macros into fuctions but it I am wondered about the performance aspects of doing this
|
|
|
|
|
There is no equivalent to macros in C#
Creating them as functions should work well; the JIT does a good job of inlining such functions.
|
|
|
|
|
thanks eric (got your book by the way )
what about optimisation? I am doing a lot of bit wise operations and rotations in 8,16, and 32 bit blocks
at the moment I have
private static uint ROL(uint x, int n)
{
return ( ((x) << ((n) & 0x1F)) | (x) >> (32-((n) & 0x1F)) );
}
private static uint ROR(uint x,int n)
{
return (((x) >> ((n) & 0x1F)) | ((x) << (32-((n) & 0x1F))));
}
would these be optimised to IL equivalents or would I have to drop to some IL layer eg is there an equivalent of _asm
Holy Handgrenade of Antioch instructions
|
|
|
|