GrapeCity MultiRow Windows Forms Documentation
TextBoxReadOnly Property (PopupCell)
Example 


Gets or sets a value that indicates whether the PopupEditingControl's text box area can be edited directly.
Syntax
<SRDescriptionAttribute("Indicates whether the PopupEditingControl text box area can be edited directly.")>
<SRCategoryAttribute("Behavior")>
<DefaultValueAttribute()>
Public Property TextBoxReadOnly As Boolean
Dim instance As PopupCell
Dim value As Boolean
 
instance.TextBoxReadOnly = value
 
value = instance.TextBoxReadOnly
[SRDescription("Indicates whether the PopupEditingControl text box area can be edited directly.")]
[SRCategory("Behavior")]
[DefaultValue()]
public bool TextBoxReadOnly {get; set;}

Property Value

true if the PopupEditingControl's text box area can be edited directly; otherwise, false.
Remarks
There are two ways to edit a PopupCell. One is to display a form or a dialog when clicking the button in the cell, and then edit the specific value type in the pop-up form. The other way is to input the text as the cell value directly in the text box area. Directly entering text may cause an incorrect format for the special type (e.g. color or font), so set this property to false to disable direct input.
Example
The following code example shows how to customize a pop-up cell's behavior or appearance. This code example is part of a larger example provided for the PopupCell class.
PopupCell CreateCustomTypePopupCell()
        {
            PopupCell popupCell1 = new PopupCell();

            // Pop up student edit form when clicking button.
            popupCell1.Popup = new StudentEditForm();
            // Use student edit form's Student property's value as cell's value.
            popupCell1.PopupValueMember = "Student";
            popupCell1.TextBoxReadOnly = true;
            popupCell1.Size = new Size(150, 21);

            return popupCell1;
        }
      

        class StudentEditForm : Form
        {
            TextBox idTextBox = new TextBox();
            TextBox nameTextBox = new TextBox();

            public StudentEditForm()
            {
                // Initialize student edit form.
                FlowLayoutPanel panel = new FlowLayoutPanel();
                panel.Size = new Size(150, 200);
                Label label1 = new Label();
                label1.Text = "Student ID:";
                Label label2 = new Label();
                label2.Text = "Student Name:";
                Button okButton = new Button();
                okButton.Text = "OK";
                okButton.DialogResult = DialogResult.OK;
                this.AcceptButton = okButton;

                this.Controls.Add(panel);
                panel.Controls.Add(label1);
                panel.Controls.Add(idTextBox);
                panel.Controls.Add(label2);
                panel.Controls.Add(nameTextBox);
                panel.Controls.Add(okButton);
                this.Text = "Student";
            }

            public Student Student
            {
                get 
                {
                    return new Student(idTextBox.Text, nameTextBox.Text);
                }
                set
                {
                    if (value != null)
                    {
                        idTextBox.Text = value.ID;
                        nameTextBox.Text = value.Name;
                    }
                }
            }
        }

        class Student
        {
            public Student(string id1, string name1)
            {
                ID = id1;
                Name = name1;
            }

            public string ID;
            public string Name;

            public override string ToString()
            {
                return "ID:" + ID + "    Name:" + Name;
            }
        }
Private Function CreateCustomTypePopupCell() As PopupCell
        Dim popupCell1 As New PopupCell()

        ' Pop up student edit form when clicking button.
        popupCell1.Popup = New StudentEditForm()
        ' Use student edit form's Student property's value as cell's value.
        popupCell1.PopupValueMember = "Student"
        popupCell1.TextBoxReadOnly = True
        popupCell1.Size = New Size(150, 21)

        Return popupCell1
    End Function
#End Region

    Private Class StudentEditForm
        Inherits Form
        Private idTextBox As New TextBox()
        Private nameTextBox As New TextBox()

        Public Sub New()
            ' Initialize student edit form.
            Dim panel As New FlowLayoutPanel()
            panel.Size = New Size(150, 200)
            Dim label1 As New Label()
            label1.Text = "Student ID:"
            Dim label2 As New Label()
            label2.Text = "Student Name:"
            Dim okButton As New Button()
            okButton.Text = "OK"
            okButton.DialogResult = DialogResult.OK
            Me.AcceptButton = okButton

            Me.Controls.Add(panel)
            panel.Controls.Add(label1)
            panel.Controls.Add(idTextBox)
            panel.Controls.Add(label2)
            panel.Controls.Add(nameTextBox)
            panel.Controls.Add(okButton)
            Me.Text = "Student"
        End Sub

        Public Property Student() As Student
            Get
                Return New Student(idTextBox.Text, nameTextBox.Text)
            End Get
            Set(ByVal value As Student)
                If Not value Is Nothing Then
                    idTextBox.Text = value.ID
                    nameTextBox.Text = value.Name
                End If
            End Set
        End Property
    End Class

    Private Class Student
        Public Sub New(ByVal id1 As String, ByVal name1 As String)
            ID = id1
            Name = name1
        End Sub

        Public ID As String
        Public Name As String

        Public Overloads Overrides Function ToString() As String
            Return "ID:" + ID + "    Name:" + Name
        End Function
    End Class
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

PopupCell Class
PopupCell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.