Skip to main content

WPF Multiline TextBox

ඔන්න අපි හදන්නේ අදත් පුංචි Tip එකක් දෙන්න. මේ ප්‍රශ්නේ මට අවේ මම පොඩි WPF Window එකක් design කර කර ඉන්නකොට.

අපි කොහොමද WPF වලදී Multiline TextBox එකක් හදාගන්නේ කියන එක තමා ඉතින් ප්‍රශ්නේ.

මුලින්ම මම කලේ ඉතින් නිකම්ම TextBox control එකක් දාගෙන එකේ තියෙන Properties එක එක බැලුව මේ වැඩේ කරගන්න විදියක් තියෙනවද කියල. මොකද Windows Forms වල නම් තියෙනවා නේ Property එකක් කෙලින්ම Multiline කියලම. ඒක true කරපු ගමන් බඩු වැඩ. ඒත් කරුමෙට මේකේ එහෙම Property එකක් තිබ්බෙත් නෑ.
පස්සේ මම ඉතින් කවදත් අපේ උදව්වට ඉන්න Google ගෙන් අහල බැලුව. මෙන්න උත්තරේ. ඇත්තටම අපිට WPF වලදී මේක ගොඩ දාගන්න Properties 3 ක් ඕනේ වෙනවා.
පහල තියෙන්නේ ඒකට අදාල xaml markup එක.

<TextBox Name="TextDescription" Height="60" Width="250" Margin="10,0,0,0" VerticalScrollBarVisibility="Visible" AcceptsReturn="True" TextWrapping="Wrap"/>

ඔන්න අපට වැදගත් වෙන එව්වා underline කරලම තියෙනවා.


VerticalScrollBarVisibility කියල කියන්නේ අපිට මේකේ scroll bar එකක් පෙන්නන්න ඕනෙද කියන එක. මේක set කරන එක අත්‍යවශ්‍යම නෑ, ඒත් ඉතින් තිබුනොත් හොඳයි.

AcceptsReturn මේකෙන් කියවෙන්නේ අපි Enter key එක press කලොත් ඒක Enter එකක් විදියට බාර ගන්න කියන්න එක, එතකොට අලුත් line එකකට යන එක තමා වෙන්නේ. මේක අපි set කලේ නැත්නම් අපේ Multiline Textbox එකේ Enter key එක press කලාට මොනවත් වෙන්නේ නෑ.

TextWrapping Property එක Wrap කියල set කලාම අපි TextBox එකේ type කරගෙන යද්දී කෙලවරට අවම ඉබේම පහල line ඒකට cursor එක යනවා.

ඉතින් ඔන්න ඔය විදියට තම අපි WPF වලදී Multiline Textbox එකක් හදාගන්නේ. ඔයාලත් කරලා බලන්න.

උපුටා ගැනීම : http://msdn.microsoft.com/en-us/library/ms742157.aspx

Comments

Popular posts from this blog

Adding Unique Constraints with Entity Framework Code First

Entity Framework Code First is a great way to define and maintain your database within your application it self. While it poses a nice set of complementing libraries like Data Annotations and Fluent Configurations which helps you specially in defining phase of your database, it would give you a headache if you try to define a unique constraint on a column. For example in the users table of your application you could probably have an int ID column which would serve as the primary key and you might need to make your Username column a unique one. Since you are using EF Code First you will soon find out there is no direct way to accomplish this requirement. Unfortunately fluent configurations doesn't have syntax like HasUnique(u => u.Username); I asked the same question in stackoverflow , but didn't get a convincing answer. Since there is no direct support from EF for this you could take one of following alternatives to achieve it. Approach 1 :  

How to disable ASP.NET page validations

ASP.NET වල page validation පාවිච්චි වෙන්නේ script injection attacks නවත්ත ගන්න, ඒ ගැන වැඩි විස්තර ඕනෙ නම් මෙතනින් බලාගන්න පුළුවන්. හැබැයි මේක අපිට කරදරයක් වෙන වෙලාවලුත් තියෙනවා. උදාහරණයක් විදියට අපි හිතුවොත් අපි අපේ user ට හිතලම ඉඩ දෙන්න ඕනේ script වගේ දේවල් page එකකට submit කරන්න. මේක උනේ මම වැඩ කරපු Admin site එකක, මේ site ඒක run වෙන්නේ company එකක intranet එකේ, මේක පාවිච්චි කරන්නේ Admin ල විතරයි ඒක අපි වෙන විදියකට authenticate කරනවා ඒ ගැන පස්සේ කියන්නම්. ඉතින් ප්‍රශ්නේ උනේ මේ page validations නිසා අපිට ඕනේ කරන user inputs ගන්න විදියක් නැති උනා. ඒක විසඳගන්න මට සිද්ද උනා page validations disable කරන්න. ඒක කරන්න ක්‍රම දෙකක් තියෙනවා. මොන දේ කරන්නත් ඉස්සෙල්ල site එකේ web.config එක පහල තියෙන විදිහට වෙනස් කරන්න ඕනේ. (සැ. යු. ASP.NET 4.0 web sites සඳහා). <configuration> <system.web> <httpRuntime requestValidationMode="2.0"/> </system.web> </configuration> ඊට පස්සේ පහල තියෙන ක්‍රම දෙකෙන් එකකට වැඩේ කරන්න පුළුවන්. Site එක

HTML INPUT enhancement with Regular Expressions and Java Scripts

අද කථා කරන්න යන්නේ බොහොම සරල දෙයක් ගැන. සරල උනාට ඉතින් මට මේක කරගන්න ඕන වෙලා හොයන කොට නම් ඉතින් හොයාගන්න ටිකක් කරදර උනා, ඒ නිසාම තමා මම හිතුවේ මේක ගැන ලියන්න ඕනෙ කියල. අපි හැමෝම HTML forms validate කරන්න Java Script පාවිච්චි කරනවා නේ, එක අලුත් දෙයක් නෙමේ. ඒ වගේම තමා Regular Expressions කියන්නෙත් අපිට අලුත් දෙයක් නෙමේ. අපි බලමු මේ දෙකම පාවිච්චි කරලා HTML textbox එකකට අපිට ඕනෙ characters විතරක් enter කරන්න දෙන්නේ කොහොමද කියල. මෙන්න මේක තමා අපි පාවිච්චි කරන HTML page එක. <!DOCTYPE html> <html> <head> <title>JS and RegEx</title> </head> <body> <label for="txtUsername">Username</lable> <input type="text" id="txtUsername" placeholder="Enter Username"/> </body> </html> මේ තියෙන page එක html විදිහට save කරලා browser එකේ බැලුවම මෙන්න මේ වගේ තමා පෙන්නේ. දැන් හිතන්න අපිට මේ username එකට @,#,%,$ වගේ