检查表单字段是否为多行 [英] check if a formfield is multiline

查看:98
本文介绍了检查表单字段是否为多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我需要使用itextsharp检查表单字段(文本字段)是否为多行。任何代码示例?



我所知道的是我需要使用PdfFormField.FF_MULTILINE但我不知道如何使用它。



我是itextsharp的新手,所以任何工作代码示例都会更有帮助。



它不是文本框而是表单域。我有以下代码:



 iTextSharp.text.pdf.PdfDictionary dic =  new  PdfDictionary(); 
dic =(iTextSharp.text.pdf.PdfDictionary)form.GetFieldItem(key).GetMerged( 0 );
// 检查文本框是否为多行。如果是,则不截断。
if (!(dic.GetAsNumber(iTextSharp.text.pdf.PdfName.FF)!= < span class =code-keyword> null && dic.GetAsNumber(iTextSharp.text.pdf.PdfName.FF).IntValue == iTextSharp.text.pdf.PdfFormField.FF_MULTILINE))
{
// 部分代码
}





以上代码无效。有人可以指出错误吗?

解决方案

TextBox.TextMode属性

获取或设置行为模式(单行,多行或密码)TextBox控件。



C#:

 [ThemeableAttribute( false )] 
public virtual TextBoxMode TextMode {获取; set ; }





ASP.NET

 < asp:textbox  textmode =TextBoxModexmlns:asp =#unknown/> 





所以:

TextBox txt = new TextBox();

... = txt.TextMode;



当TextBox控件处于多行模式时,您可以通过设置Rows属性来控制显示的行数。您还可以通过设置Wrap属性来指定文本是否应该换行.....



问候,

Alex。


Hi,

I need to check if a formfield (text field) is multiline or not using itextsharp. Any code samples?

All I know is that I need to use PdfFormField.FF_MULTILINE but I don't know how to use that.

I am new to itextsharp so any working code samples will be more helpful.

Its not the textbox but the formfield. I have the following code:

iTextSharp.text.pdf.PdfDictionary dic = new PdfDictionary();
dic = (iTextSharp.text.pdf.PdfDictionary)form.GetFieldItem(key).GetMerged(0);
//Check if textbox is multiline. If yes then do not truncate.
if (!(dic.GetAsNumber(iTextSharp.text.pdf.PdfName.FF) != null && dic.GetAsNumber(iTextSharp.text.pdf.PdfName.FF).IntValue == iTextSharp.text.pdf.PdfFormField.FF_MULTILINE))
{
 //some code
}



The above code is not working. Could someone point out the mistake?

解决方案

TextBox.TextMode Property
Gets or sets the behavior mode (single-line, multiline, or password) of the TextBox control.

C#:

[ThemeableAttribute(false)]
public virtual TextBoxMode TextMode { get; set; }



ASP.NET

<asp:textbox textmode="TextBoxMode" xmlns:asp="#unknown" />



So :
TextBox txt = new TextBox();
... = txt.TextMode;

When the TextBox control is in multiline mode, you can control the number of rows displayed by setting the Rows property. You can also specify whether the text should wrap by setting the Wrap property.....

Regards,
Alex.


这篇关于检查表单字段是否为多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆