Это немного сложнее разобрать и не совсем отвечает на мой вопрос напрямую. Максимальное количество символов TextBox (это не MaxLength)
У меня есть форма Powershell (выглядит довольно глупо), которая принимает строки и выводит их в файл .txt.
Запустите файл, введите текст, он выведет файл так, как я хотел бы. Единственная проблема в том, что большие куски текста (скажем, до 30 страниц) обрезаются после определенного ограничения символов. Как я могу удалить ограничения из текстовых полей, чтобы можно было вводить любое количество символов?
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'PCIP'
$form.Size = New-Object System.Drawing.Size(800,500)
$form.StartPosition = 'CenterScreen'
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(710,785)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(785,785)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(15,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter the author affiliations.'
$form.Controls.Add($label)
$objTextBox1 = New-Object System.Windows.Forms.TextBox
$objTextBox1.Multiline = $True;
$objTextBox1.Location = New-Object System.Drawing.Size(15,50)
$objTextBox1.Size = New-Object System.Drawing.Size(280,100)
$objTextBox1.Scrollbars = 3#Scrollbars.Vertical
$form.Controls.Add($objTextBox1)
$form.Topmost = $true
$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(15,160)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Please enter the section headings.'
$form.Controls.Add($label2)
$objTextBox2 = New-Object System.Windows.Forms.TextBox
$objTextBox2.Multiline = $True;
$objTextBox2.Location = New-Object System.Drawing.Size(15,190)
$objTextBox2.Size = New-Object System.Drawing.Size(280,100)
$objTextBox2.Scrollbars = 3#Scrollbars.Vertical
$form.Controls.Add($objTextBox2)
$label3 = New-Object System.Windows.Forms.Label
$label3.Location = New-Object System.Drawing.Point(15,300)
$label3.Size = New-Object System.Drawing.Size(280,20)
$label3.Text = 'Please enter the ISBN.'
$form.Controls.Add($label3)
$objTextBox3 = New-Object System.Windows.Forms.TextBox
$objTextBox3.Multiline = $True;
$objTextBox3.Location = New-Object System.Drawing.Size(15,330)
$objTextBox3.Size = New-Object System.Drawing.Size(280,100)
$objTextBox3.Scrollbars = 3#Scrollbars.Vertical
$form.Controls.Add($objTextBox3)
$label4 = New-Object System.Windows.Forms.Label
$label4.Location = New-Object System.Drawing.Point(15,440)
$label4.Size = New-Object System.Drawing.Size(280,20)
$label4.Text = 'Please enter the table of contents.'
$form.Controls.Add($label4)
$objTextBox4 = New-Object System.Windows.Forms.TextBox
$objTextBox4.Multiline = $True;
$objTextBox4.Location = New-Object System.Drawing.Size(15,470)
$objTextBox4.Size = New-Object System.Drawing.Size(280,100)
$objTextBox4.Scrollbars = 3#Scrollbars.Vertical
$form.Controls.Add($objTextBox4)
$label5 = New-Object System.Windows.Forms.Label
$label5.Location = New-Object System.Drawing.Point(15,580)
$label5.Size = New-Object System.Drawing.Size(280,20)
$label5.Text = 'Please enter the shortest section.'
$form.Controls.Add($label5)
$objTextBox5 = New-Object System.Windows.Forms.TextBox
$objTextBox5.Multiline = $True;
$objTextBox5.Location = New-Object System.Drawing.Size(15,610)
$objTextBox5.Size = New-Object System.Drawing.Size(280,100)
$objTextBox5.Scrollbars = 3#Scrollbars.Vertical
$form.Controls.Add($objTextBox5)
$form.Add_Shown({$objTextBox1.Select()})
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$affiliations = $objTextBox1.Text
$sectionHeadings = $objTextBox2.Text
$ISBN = $objTextBox3.Text
$TOC = $objTextBox4.Text
$shortestSection = $objTextBox5.Text
New-Item -name PCIP.txt -value "<tp>
$affiliations
</tp>
<sp>
$sectionHeadings
</sp>
<cp>
ISBN-13: $ISBN
Notice and Disclaimer
The information in this product (`“Product`”) is provided as a reference for use by licensed medical professionals and no others. It does not and should not be construed as
any form of medical diagnosis or professional medical advice on any matter. Receipt or use of this Product, in whole or in part, does not constitute or create a doctor-patient,
therapist-patient, or other healthcare professional relationship between the copyright holders and any recipient. This Product may not reflect the most current medical
developments, and the copyright holders (individually and jointly), make no claims, promises, or guarantees about accuracy, completeness, or adequacy of the information
contained in or linked to the Product. The Product is not a substitute for or replacement of professional medical judgment. The copyright holders, and their affiliates, authors,
contributors, partners, and sponsors, individually and jointly, disclaim all liability or responsibility for any injury and/or damage to persons or property in respect to actions
taken or not taken based on any and all Product information.
In the cases where drugs or other chemicals are prescribed, readers are advised to check the Product information currently provided by the manufacturer of each drug to be
administered to verify the recommended dose, the method and duration of administration, and contraindications. It is the responsibility of the treating physician relying on
experience and knowledge of the patient to determine dosages and the best treatment for the patient.
To the maximum extent permitted by applicable law, the copyright holders provide the Product AS IS AND WITH ALL FAULTS, AND HEREBY DISCLAIMS ALL WARRANTIES
AND CONDITIONS, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES OR CONDITIONS OF
MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE, OF LACK OF VIRUSES, OR ACCURACY OR COMPLETENESS OF RESPONSES, OR RESULTS, AND OF
LACK OF NEGLIGENCE OR LACK OF WORKMANLIKE EFFORT. ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, QUIET POSSESSION,
CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT, WITH REGARD TO THE PRODUCT. THE ENTIRE RISK AS TO THE QUALITY OF OR ARISING OUT OF USE OR
PERFORMANCE OF THE PRODUCT REMAINS WITH THE READER.
The respective copyright holders, individually and jointly, disclaim all warranties of any kind if the Product was customized, repackaged or altered in any way by any third party.'
</cp>
<toc>
$TOC
</toc>
<ch>
$shortestSection
</ch>
"
}
РЕДАКТИРОВАТЬ, ОТВЕТ :
Оказывается, даже несмотря на то, что документация помечает это как принадлежащее TextBoxBase (а не TextBox, для которого документация менее полна), предел символов по умолчанию составляет, по сути, ~ 32k, как предлагает плакат. Простая установка этого значения с помощью свойства MaxLength для TextBox (я установил лимит на 200000000) решает проблему.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$form = New-Object System.Windows.Forms.Form
$form.Text = 'PCIP'
$form.Size = New-Object System.Drawing.Size(800,500)
$form.StartPosition = 'CenterScreen'
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(710,785)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(785,785)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)
$label = New-Object System.Windows.Forms.Label
$label.Location = New-Object System.Drawing.Point(15,20)
$label.Size = New-Object System.Drawing.Size(280,20)
$label.Text = 'Please enter the author affiliations.'
$form.Controls.Add($label)
$objTextBox1 = New-Object System.Windows.Forms.TextBox
$objTextBox1.Multiline = $True;
$objTextBox1.Location = New-Object System.Drawing.Size(15,50)
$objTextBox1.Size = New-Object System.Drawing.Size(280,100)
$objTextBox1.Scrollbars = 3#Scrollbars.Vertical
$objTextBox1.MaxLength = 2000000000
$form.Controls.Add($objTextBox1)
$form.Topmost = $true
$label2 = New-Object System.Windows.Forms.Label
$label2.Location = New-Object System.Drawing.Point(15,160)
$label2.Size = New-Object System.Drawing.Size(280,20)
$label2.Text = 'Please enter the section headings.'
$form.Controls.Add($label2)
$objTextBox2 = New-Object System.Windows.Forms.TextBox
$objTextBox2.Multiline = $True;
$objTextBox2.Location = New-Object System.Drawing.Size(15,190)
$objTextBox2.Size = New-Object System.Drawing.Size(280,100)
$objTextBox2.Scrollbars = 3#Scrollbars.Vertical
$objTextBox2.MaxLength = 2000000000
$form.Controls.Add($objTextBox2)
$label3 = New-Object System.Windows.Forms.Label
$label3.Location = New-Object System.Drawing.Point(15,300)
$label3.Size = New-Object System.Drawing.Size(280,20)
$label3.Text = 'Please enter the ISBN.'
$form.Controls.Add($label3)
$objTextBox3 = New-Object System.Windows.Forms.TextBox
$objTextBox3.Multiline = $True;
$objTextBox3.Location = New-Object System.Drawing.Size(15,330)
$objTextBox3.Size = New-Object System.Drawing.Size(280,100)
$objTextBox3.Scrollbars = 3#Scrollbars.Vertical
$objTextBox3.MaxLength = 2000000000
$form.Controls.Add($objTextBox3)
$label4 = New-Object System.Windows.Forms.Label
$label4.Location = New-Object System.Drawing.Point(15,440)
$label4.Size = New-Object System.Drawing.Size(280,20)
$label4.Text = 'Please enter the table of contents.'
$form.Controls.Add($label4)
$objTextBox4 = New-Object System.Windows.Forms.TextBox
$objTextBox4.Multiline = $True;
$objTextBox4.Location = New-Object System.Drawing.Size(15,470)
$objTextBox4.Size = New-Object System.Drawing.Size(280,100)
$objTextBox4.Scrollbars = 3#Scrollbars.Vertical
$objTextBox4.MaxLength = 2000000000
$form.Controls.Add($objTextBox4)
$label5 = New-Object System.Windows.Forms.Label
$label5.Location = New-Object System.Drawing.Point(15,580)
$label5.Size = New-Object System.Drawing.Size(280,20)
$label5.Text = 'Please enter the shortest section.'
$form.Controls.Add($label5)
$objTextBox5 = New-Object System.Windows.Forms.TextBox
$objTextBox5.Multiline = $True;
$objTextBox5.Location = New-Object System.Drawing.Size(15,610)
$objTextBox5.Size = New-Object System.Drawing.Size(280,100)
$objTextBox5.Scrollbars = 3#Scrollbars.Vertical
$objTextBox5.MaxLength = 2000000000
$form.Controls.Add($objTextBox5)
$form.Add_Shown({$objTextBox1.Select()})
$result = $form.ShowDialog()
if ($result -eq [System.Windows.Forms.DialogResult]::OK)
{
$affiliations = $objTextBox1.Text
$sectionHeadings = $objTextBox2.Text
$ISBN = $objTextBox3.Text
$TOC = $objTextBox4.Text
$shortestSection = $objTextBox5.Text
New-Item -name PCIP.txt -value "<tp>
$affiliations
</tp>
<sp>
$sectionHeadings
</sp>
<cp>
ISBN-13: $ISBN
Notice and Disclaimer
The information in this product (`“Product`”) is provided as a reference for use by licensed medical professionals and no others. It does not and should not be construed as
any form of medical diagnosis or professional medical advice on any matter. Receipt or use of this Product, in whole or in part, does not constitute or create a doctor-patient,
therapist-patient, or other healthcare professional relationship between the copyright holders and any recipient. This Product may not reflect the most current medical
developments, and the copyright holders (individually and jointly), make no claims, promises, or guarantees about accuracy, completeness, or adequacy of the information
contained in or linked to the Product. The Product is not a substitute for or replacement of professional medical judgment. The copyright holders, and their affiliates, authors,
contributors, partners, and sponsors, individually and jointly, disclaim all liability or responsibility for any injury and/or damage to persons or property in respect to actions
taken or not taken based on any and all Product information.
In the cases where drugs or other chemicals are prescribed, readers are advised to check the Product information currently provided by the manufacturer of each drug to be
administered to verify the recommended dose, the method and duration of administration, and contraindications. It is the responsibility of the treating physician relying on
experience and knowledge of the patient to determine dosages and the best treatment for the patient.
To the maximum extent permitted by applicable law, the copyright holders provide the Product AS IS AND WITH ALL FAULTS, AND HEREBY DISCLAIMS ALL WARRANTIES
AND CONDITIONS, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED TO, ANY (IF ANY) IMPLIED WARRANTIES OR CONDITIONS OF
MERCHANTABILITY, OF FITNESS FOR A PARTICULAR PURPOSE, OF LACK OF VIRUSES, OR ACCURACY OR COMPLETENESS OF RESPONSES, OR RESULTS, AND OF
LACK OF NEGLIGENCE OR LACK OF WORKMANLIKE EFFORT. ALSO, THERE IS NO WARRANTY OR CONDITION OF TITLE, QUIET ENJOYMENT, QUIET POSSESSION,
CORRESPONDENCE TO DESCRIPTION OR NON-INFRINGEMENT, WITH REGARD TO THE PRODUCT. THE ENTIRE RISK AS TO THE QUALITY OF OR ARISING OUT OF USE OR
PERFORMANCE OF THE PRODUCT REMAINS WITH THE READER.
The respective copyright holders, individually and jointly, disclaim all warranties of any kind if the Product was customized, repackaged or altered in any way by any third party.'
</cp>
<toc>
$TOC
</toc>
<ch>
$shortestSection
</ch>
"
}