Multiline textbox with scrollbar problem


Author
Message
Russell Scott Brown
Russell Scott Brown
StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Great.  Thanks again.

Russ Brown (Using C#2010/SQL Server 2008)
Les Pinter
Les Pinter
StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Sure, here it is:

// In the MyRichTextBox class:

namespace SubClassedRichTextBoxDemo
{
  class MyRichTextBox : MicroFour.StrataFrame.UI.Windows.Forms.Textbox
  {
    public MyRichTextBox()
  {
    BindingEditable = true;
    Enabled = true;
    Multiline = true;
    ReadOnly = true;
    ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  }
 }
}


// In the form:

using System;

namespace SubClassedRichTextBoxDemo
{
  public partial class Form1 : MicroFour.StrataFrame.UI.Windows.Forms.StandardForm
  {
    public Form1()
    {InitializeComponent();}

    private void Form1_Load(object sender, EventArgs e)
    {string[] Numbers = { "Bothell", "Portland", "Seattle", "Duluth", "Dallas" };
      for (int i = 0; i <= 4; i++)
      {myRichTextBox1.Text += Numbers[i] + System.Environment.NewLine;}}

    private void button1_Click(object sender, EventArgs e)
    { myRichTextBox1.ReadOnly = false; }

    private void button2_Click(object sender, EventArgs e)
    { myRichTextBox1.ReadOnly = true; }
  }
}

I can also zip up the little app and upload it, if that would be better.

Les

Russell Scott Brown
Russell Scott Brown
StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)StrataFrame User (278 reputation)
Group: Forum Members
Posts: 124, Visits: 597
Hello Les, would you be able to provide a C# example of this?

Thanks

Russ Brown (Using C#2010/SQL Server 2008)

Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
Thanks guys.
Les Pinter
Les Pinter
StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)StrataFrame Team Member (73 reputation)
Group: Forum Members
Posts: 43, Visits: 213
Hi Aaron,

   I often need to be able to scroll a list when I'm not currently editing. I created a subclassed StrataFrame TextBox by right-clicking on the project name and selecting Add, Class (which defaults to Class1.vb), naming it MyTextBox, and then entering this for the class code:

Public Class MyTextBox : Inherits MicroFour.StrataFrame.UI.Windows.Forms.Textbox

  Sub New()
    MyBase.New()
    BindingEditable = True
    Enabled = True
    Multiline = True
    [ReadOnly] = True
    ScrollBars = Windows.Forms.ScrollBars.Vertical
  End Sub

End Class

I was then able to drop one of these on my form and get it to do what I wanted like this:

Public Class frmCustomers

  Private Sub ToolStripContainer1_ContentPanel_Load( _
   ByVal sender As System.Object, ByVal e As System.EventArgs) _
   Handles ToolStripContainer1.ContentPanel.Load

    CustomersBO1.Fill()
    Dim Numbers() As String = {"First", "Second", "Third", "Fourth", "Fifth"}
    For i As Integer = 0 To 4 : MyTextBox1.Text &= Numbers(i) & vbCrLf : Next

  End Sub

  Private Sub MaintenanceFormToolStrip1_ItemClicked( _
   ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) _
   Handles MaintenanceFormToolStrip1.ItemClicked

    Select Case e.ClickedItem.Text
      Case "Edit"
        MyTextBox1.Enabled = True
        MyTextBox1.ReadOnly = False
      Case "Save"
        MyTextBox1.Enabled = False
        MyTextBox1.ReadOnly = True
    End Select

  End Sub

End Class

This is a multiline textbox with five city names; when databound cust_City in the sample database, the only name that shows up is the one in the current CustomerBO record. Remove the databinding and all five city names appear. I'm not sure what your precise requirement is, but this may point the way.

Les

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.3K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
I don't think you've missed anything. However, it should be fairly easy to remedy. Just create your own TextBox class, and override the BindingEditable property to turn on/off the Textboxes Readonly property instead of the enable property. Since this likely is just for multiline textboxes, you could even just automatically set multiline property in the constructor too. BigGrin
Aaron Young
Aaron Young
StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)StrataFrame User (435 reputation)
Group: StrataFrame Users
Posts: 277, Visits: 1.1K
Hi,

For multiline textboxes with scrollbars, the scrollbars are disabled when the bound business object is in the idle editing state. This means a user has to enter edit mode to scroll through the textbox contents. This is the opposite of what happens with the richtextbox and syntaxeditor.

Have I missed a setting on the textbox to enable the scrollbars when in the idle editing state?

Aaron

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search