## WPF Change focused TextBox background color

Note: I'm using MahApps.Metro. So what I wanted is to create a global style which affects all TextBoxes in the application. Style should on Focus (whether it's a mouse, keyboard, whatever) change the background of the focused TextBox. My problem is...
more »

## VB.Net can't search listbox with a different term

What is wrong with the below code, when i try to search different names or delete the written name in the textbox, i get the 'Object reference not set to an instance of an object' debug error? I have a textbox, a listbox and a webbrowser object: Pub...
more »

## Saving Array of Textbox to Mysql

For some reason if I save the data it will only save the last value in the array of textbox. For example if I input two data's in array [sibling1, sibling2] it will only save the last data. Please help me, I have been searching and doing this in coup...
more »

## WPF Datagrid binding to DataTable and TextBox style in code behind

I have to show a set of data in a DataGrid having columns style as ComboBox or TextBlock. The DataGrid is binded to a DataTable. The number and position of each column in the DataTable is defined at runtime, so I create the DataGrid programmatically....
more »

## How to separate data in a text box with a separator

With this problem I have, I'm trying to separate data in a textbox, so the user could input something like this: 100,65,21,53,51,100,69 And it would return this: 100 65 21 53 51 100 69 And I would be able to parse these and use them in a mathem...
more »

## C# How to set button text of different buttons to the same textbox

I have a couple of buttons and a textbox. I want to make it so that when I press button1 the text from the textbox goes to button and when I press button2 the text goes to button2 and so on. I now have this: protected void Button1_Click(object sende...
more »

## Save data from a textbox to a specific line in an existing text file

I have a text file with these inside, Apple 5[KG] Orange 7[KG] Water 10[L] I have written this, to get a specific location from the text file //a function to get a value between two different strings public static string getBetween(string ...
more »

## Where should I put this block of codes? Please reconstruct it for me :(

I want my program to determine the empty textboxes and display the name of textboxes in a messagebox .Can you please reconstruct it for me :( Where should I put this block of codes ? FOR CLEARER REFERENCE Private Sub btnsave_Click(sender As Objec...
more »

## Convert text to integer to compare in C#

The C# program receives a string labeled: 1.2345 V I need to compare this value using < or > in a 'if' statement. How do I convert the string above to a integer? I tried to use: int anInteger; anInteger = Convert.ToInt32(textBox1.Text); anInt...
more »

## How to remove first line text from text-box?

What wrong with my code as below: Select Case chkSTC.Checked Case True txtCargoDescription.Text = Resources._Global.ContrSTC & vbNewLine & txtCargoDescription.Text Case False Dim b As String() = Split...
more »

## How to disable certain string inside text box?

What I done as code below show that all the data inside text-box was disable. Private Sub chkSTC_CheckedChanged(sender As Object, e As System.EventArgs) Handles chkSTC.CheckedChanged Select Case chkSTC.Checked Case True ...
more »

## How to capture the cursor position in a textbox?

I have a TextChanged event on my Masked TextBox and I want that its method be called just when the cursor stay at the end. For example: 222.222.2/21 The event shall be called as soon as the user types "1". XAML <TextBox Name=...
more »

## PowerShell limit entries in text boxes to integer values only

A small program with Windows Forms in PowerShell shall contain a calculator. I decided to use TextBoxes as input method, however I can't convert the content of these textboxes to integers. How would I limit the entry in textboxes to integer-only or...
more »

## How to use mathjax in placeholder of textbox in asp.net?

I recently added MathJax to my webform, I'm able to do everything except figure out how to use MathJax as a placeholder inside a TextBox. example: <asp:TextBox ID="textbox1" placeholder="$x^2$"></asp:TextBox> My placeholder doesn't wa...
more »

## How to Bind a TextBox in DataGrid to a List in Wpf?

Am working on a new Wpf project and struggling with Binding a TextBox in DataGrid to a List of objects in Wpf. Can anyone help me to fix? This is my code (simplified version) to generate the Datagrid rows by binding my Orders object. User can chang...
more »

## Restrict TextBox input upto particular value without disturbing cursor position

I have a WPF application(MVVM) .I want to restrict user from entering more than specific value in a TextBox. Suppose that value is '100' , then user shouldn't be able to enter 101 etc. I have tried following code. XAML: <TextBox Text="{Binding S...
more »

## C# When is TextBox.Text.Length < TextBox.SelectionStart

While implementing a Behavior for a TextBox in WPF, I saw numerous examples, that use the PreviewTextInput event to handle new input. Some of the examples (e.g. techqa.info) have a condition implemented that I don't understand: if (textBox.Text.Leng...
more »

## WPF TextBox no Space allowed

I want a user to only write numbers (0-9) in a TextBox. I'm using following code to prevent the user of writing letters and other characters except of numbers, but I can't avoid the user to use the space in the TextBox. private void CheckIsNumeric(T...
more »

## Constraint length of Text in TextBox by its encoded representation

I have a TextBox in WPF. I want to restrict the length of the text in the TextBox. There is an easy way to restrict the number of characters by the property MaxLength. In my use case I need to restrict the text not by the number of characters but by...
more »

## How to Disable Paste option for alphabets and Special Characters but Enabled for Numbers

I Used this code for restricting to type alphabets and characters. <script type="text/javascript"> function isNumber(evt) { evt = (evt) ? evt : window.event; var charCode = (evt.which) ? evt.which : evt.keyCode; i...
more »

## Regex to allow a user to type in a time - C#

Lots of other questions give answers for regex expressions which only allow fully completed times like this: ^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]\$ But this is no use in a Textbox.TextChanged event because while typing 15:45 the textbox will cont...
more »

## how fill combobox with all records of a person from database based on his name on textbox?

here is my code but its retrieve only last record not all SqlConnection history= new SqlConnection("Data Source=.;Initial Catalog=db3;Integrated Security=True"); history.Open(); SqlCommand histcmd= new SqlCommand...
more »

## Not to clear textbox on page reload or button click event

I have developed a website in C# asp.net which contains a Master Page. I have designed a top menu with Search bar(txtSearch) and a button(LinkButton). When I click on search button it redirects to the page where searched data is to be displayed but w...
more »

## WPF control extra pixels source

I have these simple wpf controls in this layout. My question where is the extra pixels coming from in the TextBox. It looks like the TextBox is not respecting the Width='Auto' property. I'm looking to make the Grid Column 0 width equal exactly to th...
more »

## WPF TextBox disable break on special characters

I have a TextBox defined like this: <TextBox Text="{Binding License.LicenseKey}" HorizontalContentAlignment="Left" TextAlignment="Justify" Width="350" Height="100" Margin="10,0,0,0" TextWrapp...
more »

## Make WPF TextBox Margins Clickable/Selectable

I have a WPF TextBox with a white background. I've given it some Padding so that the text has a "margin" around it (akin to the margins in, say, MS Word). <TextBox x:Name="MyTextBox" Padding="25" /> Unlike in Word, however, this blank area a...
more »

## C# Right to Left in TextBox

I try to do TextBox moving, for Rss updates, but the problem is that the Rss text is also in Hebrew in English and also numbers, so every time it reaches the number it starts to go crazy :) Exmaple Rss = " * ynet - מבזקים * Ynet * ביקו
more »

## saving Textbox values for next time I run an application

I have a form with 30 text boxes which contain default setting I set in my code. the user has an option to change it , but I want to know how can I save the new values chosen by the user in one (or more) of those text boxes for next time I run the ap...
more »

## Press an "@" and drop-down a ComboBox. [C#]

First of all sorry if this is repeated, but I didn't find anything yet about that. Is it possible in C# to press a specific key on a TextBox, in this case "@", and dropdown a list of names? It's the same thing that FB and Whatsapp does now. In order...
more »

## how to get value from dynamically created textbox in asp.net

hi i'm Cannot get value dynamically created textbox and save into database. plz help his is code which I have created in this code text box are created but when I will input the value in the text and retrieve the value from dynamically created text b...
more »

## I am trying to scale the background image of a TextBox but it is cropped

I have a TextBox in which I want to add an image as background. The first try is this: <TextBox Text="{Binding Titulo}" Height="Auto" HorizontalAlignment="Stretch" Margin="5,5,5,5" Name="txtTitulo" VerticalAlignment="Stretch" TextAlignme...
more »

## search in DataGrid by textBox WPF

I have grid with 10-15 columns. (I load data by datagrid.ItemsSource = myList.ToList()) Also I have textBox witch textChanged event. When I put here eg. "cat" I want to see only rows with value ...cat... how do I make this? ...
more »

## How to reset drop down list back to default when there is nothing in textbox?

I have a textbox #Email and I have two dropped down list menus that is #Carriers and #Phones. When the Email is entered I want to enable only Carriers drop box but not the Phones. When the Carriers is selected the Phones dropdownlist has to be enable...
more »

## How to handle Ctrl + Enter with TextBox when AcceptsReturn is true?

In my UWP application, I want my TextBox to be able to go to new line by pressing down the Enter key but I also need to trigger an action when Ctrl+Enter are pressed. The issue is, I can't seem to find a way to prevent the text to go to the next li...
more »