Spread Windows Forms 12.0 Product Documentation
CanFocus Property (ElementControl)
Example 


FarPoint.Win Assembly > FarPoint.Win Namespace > ElementControl Class : CanFocus Property
Gets or sets whether the control can receive focus.
Syntax
'Declaration
 
Public Overridable Shadows Property CanFocus As Boolean
'Usage
 
Dim instance As ElementControl
Dim value As Boolean
 
instance.CanFocus = value
 
value = instance.CanFocus
public virtual new bool CanFocus {get; set;}

Property Value

Boolean value: true if element can receive focus; false otherwise
Remarks

If this property is set to true, you can check whether the control has the focus, or move the focus to the control, by calling the Focus method or check whether the control has the focus using the Focused property.

If you do not want the control to receive focus nor for the user to interact with it, set the Enabled property to false.

For some controls, when the control receives the focus, if it can, the control can display a focus rectangle. Specify whether and how the focus rectangle appears by setting the DrawFocusRectangle property.

Some controls display a cursor when they receive the focus. Specify the position of the cursor by setting the EditModeCursorPosition property.

Contrast this property with the Enabled property and the Selectable property. Use the Enabled property to specify whether the control looks grayed and users can interact with it. Use the Selectable property to specify whether users can interact with the control, such as pressing a button.

Example
control.Picture = Image.FromFile(Application.StartupPath + "\\smokes.bmp");
control.PictureMargin = 34;
control.MarginTop = 3;
control.MarginBottom = 3;
control.MarginLeft = 3;
control.MarginRight = 3;
control.PictureOrientation = FarPoint.Win.PictureOrientation.PictureRotate180;
control.AlignText = FarPoint.Win.TextAlign.TextLeftPictRight;
control.AlignHorz = FarPoint.Win.HorizontalAlignment.Left;
control.BackColor = Color.Red;
control.Text = "NO SMOKING";
private void button1_Click(object sender, System.EventArgs e)
{
// Turn off the No Smoking sign
control.Visible = true;
control.Enabled = false;
control.Selectable = false;
control.CanFocus = false;
}
control.Picture = Image.FromFile(Application.StartupPath & "\smokes.bmp")
control.PictureMargin = 34
control.MarginTop = 3
control.MarginBottom = 3
control.MarginLeft = 3
control.MarginRight = 3
control.PictureOrientation = FarPoint.Win.PictureOrientation.PictureRotate180
control.MarginTop = 3
control.MarginBottom = 3
control.AlignText = FarPoint.Win.TextAlign.TextLeftPictRight
control.AlignHorz = FarPoint.Win.HorizontalAlignment.Left
control.BackColor = Color.Red
control.Text = "NO SMOKING"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'Turn off the No Smoking sign
control.Visible = True
control.Enabled = False
control.Selectable = False
control.CanFocus = False
End Sub
See Also

Reference

ElementControl Class
ElementControl Members
Focus(Boolean) Method
DrawFocusRectangle Property
EditModeCursorPosition Property
Enabled Property
Focused Property