|
Hi,
this is my first question on CodeProject; its about Visual Designer.
Say I want to have a Panel and a PictureBox in the Form, no problem.
Now a Button in that Panel, no problem, just click in the Panel and drag a Button.
Now a Label in that PictureBox, Designer does not do that, even when I click inside
the PictureBox, the Label gets added to the Form, not to the PictureBox
(code checked: parent is Form, location is Form relative).
Also not working is Button in Button.
Is there a way to do these with Designer, i.e. without changing the code manually ?
If it is impossible for some Controls, which are they ? How can one recognize them ?
I am using both Visual 7.1 and 8.0 (in case it would be different).
TIA
-- modified at 20:38 Sunday 4th February, 2007
Luc Pattyn
|
|
|
|
|
I only VS .net
Some controls are not containers.
|
|
|
|
|
Luc Pattyn wrote: If it is impossible for some Controls, which are they ? How can one recognize them ?
I think you cannot recognize them. For example, the GroupBox and PictureBox are both direct inheritors of Control , but a dragged control is only added to the group box. So the designer is obviously following his own logic where it is sensible to add the dragged control to the form or the control it was dragged to, respectively.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hello Luc,
Isn't the interface "IContainer" responsible for that behavior?
All the best,
Martin
-- modified at 8:45 Monday 5th February, 2007
|
|
|
|
|
i'm using devenv to compile projects
say
Process.start("devenv",@"<solution> /build Debug ........... /out C:\BuildLog.txt");
the next piece of code is:
StreamReader sr = new StreamReader("C:\\BuildLog.txt");
string line;
while((line = sr.ReadLine()) != null)
{
LogText += line;
}
this throws a filenotfound exception the first time. on running the application again, it finds the file and displays its contents too...
the file gets appended with every run. but on reading it thru this code it does not read the latest chunks written to file.
for eg say
the file contains
abc
xyz
def
the file reads only abc xyz
and the next time it runs it reads abc xyz as well as def... but by then.... more chunks r appended.
Kindly help.
thanks in advance.
|
|
|
|
|
You must have code that is creating this file, so that the next time it runs OK. Does your write code rewrite the entire file, or just append to it ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
thanks for replying.
the file is automatically created as the application is compiled
devenv .....(args...) /out c:\\BuildLog.txt
creates/appends the file buildlog.txt
i don't write anything to this file at all. i just need to read it and display all of its contents.
thanks and regards,
Acec0d3r
|
|
|
|
|
maybe this helps :
http://www.codeproject.com/cs/threads/launchprocess.asp
VirtualVoid.NET
|
|
|
|
|
My app has a CheckedListBox, after added items, not be able to gray out some items so users can't select them.
Any one has solution?
Thank you.
|
|
|
|
|
I don't think it's possible to do without some custom drawing. You might try overriding OnPaint and see if you can do some drawing in there to manually gray out a particular item.
|
|
|
|
|
OK I tried to double chech (5 times at least acctually) all things, still when I replace
this code:
<code> HttpChannel c = new HttpChannel(32469);
ChannelServices.RegisterChannel(c);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(SimpleChatProgram_DLL.SimpleChatProgramLibrary),
"RemoteMsgObj.soap", WellKnownObjectMode.Singleton);</code>
with this one
<code> RemotingConfiguration.Configure("App.config", false);</code>
and
this config file:
<code><configuration>
<system.runtime.remoting>
<application>
<service>
<wellknown
mode="Singleton"
type="SimpleChatProgram_DLL.SimpleChatProgramLibrary, SimpleChatProgram_DLL"
objectUri="RemoteMsgObj.soap"/>
</service>
<channels>
<channel ref="http" port="32469" />
</channels>
</application>
</system.runtime.remoting>
</configuration></code>
my client app (very simple program btw), stop working it can't even start anymore...
Server start just as usual, but doesn't work as expected...
Any idea?
|
|
|
|
|
Any idea guys, I tried bunch of mine, but none give expected results, guess it's something trivial..
|
|
|
|
|
try the filters ... unfortunately i forgot the right syntax, but it have something to do with soap or binaryfilter...
<channels>
<channel ref="http" useDefaultCredentials="true" port="0">
<clientProviders>
<formatter ref="soap" typeFilterLevel="Full"/>
</clientProviders>
<serverProviders>
<formatter ref="soap" typeFilterLevel="Full"/>
</serverProviders>
</channel>
</channels>
i cut/copy this from my own project, maybe it helps you
VirtualVoid.NET
|
|
|
|
|
I still didn't got this working...
|
|
|
|
|
I've recently come over to VS/C# from Delphi, and I know this is a basic question, but I am seemingly wading through far too much documentation to find the answer.
I want to use a struct or Object as a property of a component. In Delphi, any such property declaration automatically resulted in an expandable node in the IDE, displaying all the properties of the struct or Object within the root component.
I see in the VS library documentation now that structs such as Size and Rectangle do expose themselves to the IDE by way of editors. I have not written whatever required editor, but without the editor, my struct or Object property appears as grayed out text in the Property window. I believe I've properly set up the attributes for my intended property. But in any case, I cannot edit the struct or Object property in the Properties window.
Can anyone just confirm for me that indeed I do (or do not) have to write an editor, and perhaps point me toward what kind of editor to write, and what VS documentation to see for reference?
Much thanks in advance,
mike
|
|
|
|
|
mike montagne wrote: In Delphi, any such property declaration automatically resulted in an expandable node in the IDE, displaying all the properties of the struct or Object within the root component.
That doesn't happen here. You can use attributes to make a property appear in the designer, and if it's a struct, you could mark those properties as well. I think it's [Browsable].
The real question is, why do you need to set it in the designer ? But, I believe the problem is, the designer knows nothing about your struct, you need to set it up to expose the properties of the struct.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Setting the Browsable attribute hasn't seemed to be enough. I will try setting up the designer and report the results when I get around to that (hopefully later today).
Thanks, Christian.
m
|
|
|
|
|
Marking the struct/Object property [Browsable] in the root component, and marking the struct/Object property members [Browsable] as well, does not alleviate the grayed/disabled struct/Object property listing in the root component.
As to identifying what to do in the way of an editor/designer (or whatever is required), I'm still (so far) only finding plank after plank of documentation that doesn't answer the question.
Does anyone know what kind of editor/designer I need to investigate here? It would seem that example code for editors such as Rectangle or Size would do the trick.
If I stumble on the answer eventually otherwise, I shall post.
TIA,
m
|
|
|
|
|
It doesn't look to me so far that UI Type Editor will solve the problem. You can only override GetEditStyle() for instance to render a drop-down control or a modal dialog. That itself rules out the nested node behavior I'm after... and the walkthroughs are not treating a whole object descendant as a property... so they aren't really showing me what I need to do (and seem to apply instead to simply interfacing a class or type for which there is not applicable editor behavior for a singular set of values (versus numerous member properties)).
Striking out so far... and have a feeling this is far simpler than wading through all this.
|
|
|
|
|
Another possibility is that Interfaces are the intended solution.
Getting warmer or colder with this shot in the dark?
|
|
|
|
|
Christian,
If you don't mind, I'm trying still to decipher your post.
First you say, "That doesn't happen here." But you add, "You can use attributes to make a property appear in the designer, and if it's a struct..."
I believe by the latter you may mean, "That doesn't happen here, unless you use the attributes, XAttribute, YAttribute, etc. (or something to that effect)." Your next question appears to reinforce the idea I don't need a designer.
Anyway, I'm sorry to ask this again, but I need to be clear on this. Is your thinking that I should not have to write a designer -- that [Browsable] and [Serializable] should do the trick without a designer?
I'm not getting either to work.
TIA,
m
|
|
|
|
|
Hello,
mike montagne wrote: my struct or Object property appears as grayed out text in the Property window
Happens normaly only if you have set the Readonly attribute or youre property has no setter.
Here you find everything you need:
http://www.codeproject.com/cs/miscctrl/customizingcollectiondata.asp[^]
This article helped me a lot.
All the best,
Martin
|
|
|
|
|
Hmmm.
I have both set and get. Here is the property definition in the client class. Please excuse the mess from the experimental state:
[Browsable( true )]
[Category( "Appearance" )]
[Description( "Caption margins, relative to layout. Default = new GCMargins( enumMarginGroup.mgLeft, 3, 26, 3, 3, 3, 3 )." )]
[DesignerSerializationVisibility( DesignerSerializationVisibility.Visible )]
[NotifyParentProperty( true )]
public GCMargins Caption_Margins
{
get
{
return f_Caption_Margins;
}
set
{
f_Caption_Margins = value;
P__InvalidateConditionally( );
}
}
I don't find the article to pertain to my situation; and your answer suggests that your experience is that I *should* be getting a nested property in my client class, even without writing an editor. Is that so?
I've been doing walkthroughs from the VS documentation with no success whatsoever.
TIA,
m
|
|
|
|
|
PS.
Here also is the initial declaration of my property class and its internal fields. Each of the fields is exposed as a property marked with the [Browsable] attribute, and with both get and set methods. But I have nothing but a grayed out property name in my client class:
{
[Serializable]
[ToolboxItem( true )]
[DesignerAttribute( typeof( GCMargins_Designer ) )]
public class GCMargins : Object
{
private enumMarginGroup f_AlignmentGroup;
private Int32 f_Bottom_TopOrBottomAligned;
private Int32 f_Left_LeftOrRightAligned;
private Int32 f_LeftAndRight_TopOrBottomAligned;
private Int32 f_Right_LeftOrRightAligned;
private Int32 f_Top_TopOrBottomAligned;
private Int32 f_TopAndBottom_LeftOrRightAligned;
Here are the property definitions:
#region PROPERTIES
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Determines margin deployment. AlignmentGroup membership is reflected by margin nomenclature." )]
public enumMarginGroup AlignmentGroup
{
get
{
return f_AlignmentGroup;
}
set
{
if ( value != f_AlignmentGroup )
f_AlignmentGroup = value;
}
}
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Bottom margin, top or bottom aligned. Minimum = 2." )]
public Int32 Bottom_TopOrBottomAligned
{
get
{
return f_Bottom_TopOrBottomAligned;
}
set
{
if ( value != f_Bottom_TopOrBottomAligned )
f_Bottom_TopOrBottomAligned = Rectify( value );
}
}
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Left margin, left or right aligned. Minimum = 2." )]
public Int32 Left_LeftOrRightAligned
{
get
{
return f_Left_LeftOrRightAligned;
}
set
{
if ( value != f_Left_LeftOrRightAligned )
f_Left_LeftOrRightAligned = Rectify( value );
}
}
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Left and right margins, top or bottom aligned. Minimum = 2." )]
public Int32 LeftAndRight_TopOrBottomAligned
{
get
{
return f_LeftAndRight_TopOrBottomAligned;
}
set
{
if ( value != f_LeftAndRight_TopOrBottomAligned )
f_LeftAndRight_TopOrBottomAligned = Rectify( value );
}
}
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Right margin, left or right aligned. Minimum = 2." )]
public Int32 Right_RLAligned
{
get
{
return f_Right_LeftOrRightAligned;
}
set
{
if ( value != f_Right_LeftOrRightAligned )
f_Right_LeftOrRightAligned = Rectify( value );
}
}
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Top margin, top or bottom aligned. Minimum = 2." )]
public Int32 Top_TopOrBottomAligned
{
get
{
return f_Top_TopOrBottomAligned;
}
set
{
if ( value != f_Top_TopOrBottomAligned )
f_Top_TopOrBottomAligned = Rectify( value );
}
}
[Browsable( true )]
[Category( "Appearance" )]
[DefaultValue( 3 )]
[Description( "Top and bottom margins, left or right aligned. Minimum = 2." )]
public Int32 TopAndBottom_LeftOrRightAligned
{
get
{
return f_TopAndBottom_LeftOrRightAligned;
}
set
{
if ( value != f_TopAndBottom_LeftOrRightAligned )
f_TopAndBottom_LeftOrRightAligned = Rectify( value );
}
}
#endregion PROPERTIES
TIA,
m
|
|
|
|
|
Martin# wrote: Happens normally only if you have set the Readonly attribute or your property has no setter.
I must also say that the VS walkthroughs are not providing my answer, and I believe this may be because (as Martin's posts seems to suggest) that I should be getting a nested property node in my client class automatically (although this appears to conflict with Christian's answer).
The documentation for PreFilterProperties states:
Allows a designer to add to the set of properties that *it exposes* through a TypeDescriptor.
Being as TypeDescriptors assumably expose all declared public properties via Reflection, I assume this means I should not have to toy with an editor (which doesn't seem to be solving the dysfunctional property listing in the client class, anyway).
?????
|
|
|
|
|