Name property of UserControl or Control - visual-studio

What is special about the Name property of a Control or UserControl that causes it to be displayed as "(Name)" inside the property grid within Visual Studio?

Check out this article about design-time attributes in .NET. Specifically, I think you are looking for the Browsable attribute, which enables properties in Visual Studio's design-time properties dialogue.
If you have a property called Name, you'd declare it like this:
[Browsable(true)]
public string Name { /*...*/ }
You can set a lot more attributes, like Description, DefaultValue and Category, which will come in handy if you're planning on presenting your controls to other developers.
EDIT: To get the effect that you want, use both the Browsable and ParenthesizePropertyName attributes:
[Browsable(true)]
[ParenthesizePropertyName(true)]
public string Name { /*...*/ }
(Thanks to Ksempac from the comments for this.)
Since you didn't specify if you're using VB or C#, here's the same thing in VB:
<Browsable(true)> _
<ParenthesizePropertyName(true)> _
Public Property Name(Value As String) As String
' ...
End Property
EDIT 2:
I think you're wondering about why you would want to surround your property with parentheses in the first place, or perhaps what it means for a property's name to have parentheses around it.
You can find the answer to that here:
Parenthesized properties are shown at the top of the window — or at the top of their category if the list is grouped by category
Basically, if a property is important, you want it to appear at the top of a sorted list, so you surround it with parentheses to indicate this.

Related

How to get content from field

I'm totally new to Base. I have different forms but in one named F_STRUCT of them I'm trying to make a macro which will allow the user to autofill another field when he select a zipcode.
so the database looks like this.
ID_ZIP ZIP CITY
1 97425 Les Avirons
2 82289 Toto
In my forms, I have a select which allows to select the ZIP code. It's label and name is ZipCode.
So I don't really know where to find the API reference for all the methods and chill methods, I followed examples from internet.
I tried this
Sub getZip
Dim Doc As Object
Dim DrawPage As Object
Dim Form As Object
Doc = StarDesktop.CurrentComponent
DrawPage = Doc.DrawPage
Form = DrawPage.Forms.GetByIndex(0)
Toto = Form.GetByName("ZipCode")
Print "hey"
End Sub
But it returns an error on the Toto = Form.GetByName("ZipCode") line.
The code works, so the problem must be how you created the form or control. Follow these instructions to set up a correct example:
Create Form in Design View
Use the List Box tool (is that what you mean by "select"?) and create a control.
Cancel out of the wizard if it pops up.
Right-click on the control and select Control Properties (not Name, which would modify the shape name instead of the control's name).
Set the Name to "ZipCode" (without quotes).
Save and close the form.
Open the form. In the window of that form (the CurrentComponent) go to Tools -> Macros -> Run Macro.
A list of documentation links for Base is at https://ask.libreoffice.org/en/question/80972/to-learn-libreoffice-base-are-there-introductions-or-tutorials/?answer=80973#post-id-80973.

ADD OBJECT to subcontainer of object being defined

I'm writing a program to generate a VFP form class with lots (90+ each) of labels and radio buttons on it. That's the easy part. (and yes, I know that's a lot of radio buttons, but that's what the users want).
We have several VCXs in our application which do something similar, but not with anywhere near as many individual controls. So, rather than spend a huge fraction of my life dragging and dropping fields around, and realizing that I happen to have a handy list of all the fields, their options and default values, I used the 'View Class Code' option from the Class Browser to get a sample of what the code looks like as a base. Then I wrote code to generate a PRG with all the pieces I need.
My actual problem is that the code output by 'View Class Code' seems to include invalid syntax:
DEFINE CLASS form40 AS frmae
Height = 427
Width = 710
ScrollBars = 2
DoCreate = .T.
Visible = .T.
Name = "form40"
ADD OBJECT form40.cntouter.cntform40 AS cntctrls WITH ;
Top = 175, ;
Left = 2, ;
Visible = .T., ;
Name = "Cntform40"
ENDDEFINE
The class frmae is a class (from a VCX) which includes a container called 'cntouter'. Class cntctrls is the container that contains all the labels/radio buttons.
The problem is that apparently you can't, in the DEFINE CLASS command, ADD OBJECT to a member. The dotted syntax causes a syntax error. Yet, this technique is used in the 'View Class Code' output.
I suspect I could get around this by generating an Init method which calls ADDOBJECT() to add my control container to cntouter, but I'd rather have it in the class definition.
The "View Class Code" option doesn't produce runnable code; it never has.
My suggestion for doing what you need is to create an option button class with the appearance that you want. Then, use your existing list to populate a cursor and write code that spins through that and adds option buttons to a container class.
The key thing you need to know here is that you can run code in the IDE that affects a form or class that's open in the Form Designer or Class Designer. That's what Builders do. So rather than generate a code-based class, use code to create a visual class.
If you want to do this in code, then first you shouldn't depend view code as Tamar already pointed out. You can do any form and its controls in code (with the exception of one or two activex controls maybe) but you need to understand how to code container type controls. First, to add a class from a class library you need to sepcify its source. ie:
add object myContainer as MyBeautifulContainer from myClasslib.vcx
wouldn't work. Instead you would need to define a class in your code like this:
define class form40 as form
* ...
add object myContainer as MyContainer with ...
* ...
enddefine
define class myContainer as MyBeautifulContainer from myClasslib.vcx
* additiobnal code if any
enddefine
Second, you would need to create your inner controls first and then add as needed to create the outermost object.
AT designtime, you could go to command window, pop up a code window:
modify command [enter]
and then using ASELOBJ() function you can get a reference to any object on the form you are designing. Onece you have the desired reference(s), you can add and arrange objects within that code window programmatically, select the code and execute selection (erase the controls, correct your code and retry if you can't do it right for the first time). That is temporary "do and throw away" style builder.

PHPDoc: How to hide private properties and methods

The documentation just shows that an xml configuration property exists for visibility, but doesn't show how to use it. The documentation for the command line equivalent shows:
–visibility[=”...”]
Provide a comma-separated list of visibility scopes to parse.
This parameter may be used to tell phpDocumentor to only parse public properties and methods, or public and protected.
There are private properties that are showing up in my documentation and I'd like to hide them. I've tried <visibility>public</visibility> but it appears to have no effect.
Update
I'm currently using the default template. It both lists the private methods and shows a "Private Methods" section on the template.
If that --visibility flag is not working, it must be a bug. Then again, it's possible that some output templates display the three visibility view toggles even if the document generation execution was run with only "public" being enabled.
In the resulting docs you've generated with a particular template, are you still seeing all three visibility buttons showing? If so, enable the private and protected buttons, then see if any private/protected properties/methods actually do become visible. It might be that you are getting only public things documented, but just still seeing the private/protected toggle buttons in the view.
This works for me --visibility="public"
The visibility element works. Put inside
<parser>
<visibility>public</visibility>
<target>docs/api</target>
</parser>

How may I prevent the Designer changing control member modifiers to private?

When in the Designer I change a property of a DataGridViewColumn on which I previously manually changed the modifier to public in the .Designer.cs file, the modifier gets reverted to private.
Is there any way to prevent this?
I would recommend not changing the designer.
If you really need to have your controls public, I would recommend adding a property to expose them in your code file (not the designer file):
public TextBox MyTextBox { get { return this.textBox1; } }
This will provide public access to the designer generated types without worry of the designer overwriting your changes.
It also makes it much more clear, in the long run, since your public API is defined in your main code file, and not in a second, designer generated file.
That being said, in general, I'd avoid this. Instead of exposing the control itself, I would actually recommend exposing the data that you want to set. Take the text box above - If this text box was a title, I would expose that directly:
public string Title
{
get { return this.textBoxTitle.Text; }
set { this.textBoxTitle.Text = value; }
}

Styling an extended TextBox control in Windows Phone 7

Totally new to custom control creation in Silverlight.
I'm wanting a custom control that inherits from a TextBox control. I've found plenty of tutorials but they all do something like watermarked text or other attached properties. My goal is only to manipulate text at time of entry using the KeyUp event, so visually my TextBox is no different from a standard TextBox.
I created a class file and inherited from TextBox, but at run-time the textbox doesn't display. From what I can gather I need a themes/generic.xaml file, but all of samples I've seen include styles for the additional properties, and in my ignorance I don't know what to change and/or remove.
I'm hoping someone can point me to a generic plain-jane TextBox style definition or a tutorial of such.
What you described should work, I just tried the following and the TextBoxEx renders just fine:
public class TextBoxEx : TextBox
{
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
}
}
You do not need to add a generic.xaml file. This file is used to provide a template which defines the look of your control. You specify the default look of your control by setting the following property:
DefaultStyleKey = typeof(MyControl);
However, as the above TextBoxEx does not set this property, it uses the value inherited from TextBox and hence it inherits the same template (i.e look).

Resources