Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i have an app in c# having 2 textbox.When i select the first one and type i should get the malayalam font and when i select the other textbox, i should get the text in english. For this i set the font of first textbox to malayalam and font of second textbox to english-arial.
and when i run the program both the text box displays english letters when i type. By pressing alt+shft keys and swapping the input language, then both textboxe's inputs become malayalam. I want to type malayalam in one textbox and english in other textbox without swapping the input language using alt+shft
Thank you
You have to select malaya language on text box enter event and back to english language selection on leave event as below:
private void textBox1_Enter(object sender, EventArgs e)
{
System.Globalization.CultureInfo TypeOfLanguage = new System.Globalization.CultureInfo("ms-MY");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(TypeOfLanguage);
}
private void textBox1_Leave(object sender, EventArgs e)
{
System.Globalization.CultureInfo TypeOfLanguage = new System.Globalization.CultureInfo("en-us");
InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(TypeOfLanguage);
}
Hope that was helpful.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want to create a TextBox in windows form application in visual studio that contains only specific numbers. for example i want one textbox to be able to contain only numbers between 0 and 1. If its any other value I want a message to appear that says wrong number. The app is in written in C#.
I have seen this example
C# Numeric Only TextBox Control
but it is for numeric and i want specific numeric.
Edit:My mistake i wasn't clear enough. i tried the NumericUpDown but it doesn't work for all examples. In the second box i want to have values from 20 to 340 but only the .5 floating points between (20,20.5,21 etc) and if i use NumericUpDown, if the user inserts 22.6 the cell accepts it and i don't want that. That's why i ask if it's possible to control the value inserted with a Textbox or a MaskedTextBox and if it's eligible then for the user to be able to enter it the box. Hope i am clear enough now.
You should use a NumericUpDown.
You can use it like this;
NumericUpDown control = new NumericUpDown();
control.Minimum = 0;
control.Maximum = 1;
control.DecimalPlaces = 2; // or something you want.
control.Increment = .01; // step is .01
create user control inheriting TextBox and add an event for KeyPress as follows
public class MyTextBox:TextBox
{
List<int> numberstobeallowed = Enumerable.Range(20, 340 - 20).ToList();
public MyTextBox()
{
this.Leave += new EventHandler(MyTextBox_Leave);
}
void MyTextBox_Leave(object sender, EventArgs e)
{
if (numberstobeallowed.Contains(Convert.ToInt32(this.Text)))
this.Text = string.Empty;
}
}
hope this helps
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I want to get data from textbox and write it to file. I have this code, but it's not working.
private void Button_Click_2(object sender, RoutedEventArgs e)
{
string info = textbox2.Text;
List<string> data= new List<string>();
data.Add(info);
String line = File.WriteAllLines(filename, data);
}
What am I doing wrong?
1. you are trying to store the return value of the function File.WriteAllLines() into String variable line but File.WriteAllLines() does not return anything it's return type is void
2. you can use File.WriteAllText() function to write your string entered in TextBox.
Try This :
private void Button_Click_2(object sender, RoutedEventArgs e)
{
File.WriteAllText(filename, textbox2.Text);
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I want write a program that :
In textbox type a picturebox name and in other textbox type location number,then press button to move that picturebox that name is equal textbox1 to that location.
my question is how I can send a object(picturebox) to a Function?
If I understand you correctly you want to move a picture box by entering its name into a textbox? Then this is a possibility:
private void button_click(object sender, EventArgs e)
{
string pBoxName = textbox1.Text;
// I don't quite understand what you mean by 'location number'
int newPos = int.Parse(textbox2.Text);
// boxList is a List<PictureBox>
PictureBox pBox = boxList.Where(x => x.Name.Equals(pBoxName)).FirstOrDefault();
if(pBox != null)
{
MoveTheBox(pBox, newPos);
}
}
private void MoveTheBox(PictureBox box, int newPos)
{
// move the box
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Here my requirement is to assign + and - to a number both at a time to a number in the label as shown in bellow image in c# asp.net!
Use unicode character "PLUS-MINUS SIGN".
Its code point is (U+00B1)
label.Text = "\u00B1"
The Unicode character Plus-Minus-Sign has the code 00B1, and the unicode escape sequence in C# is \u followed by 4 hex-digits.
you could add two other labels with an other font size and a Click-Event to count up or down.
private void minus_Click(object sender, EventArgs e)
{
this.number.Text = Convert.ToInt32(this.number.Text) - 1 + "";
}
private void plus_Click(object sender, EventArgs e)
{
this.number.Text = Convert.ToInt32(this.number.Text) + 1 + "";
}
where "number" ist you number label.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions must demonstrate a minimal understanding of the problem being solved. Tell us what you've tried to do, why it didn't work, and how it should work. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Im wondering how to make my textbox format "DD.MM.YYYY" that after load form the textbox will be filled with "__ .__ .__" and those spaces and dots cannot be deleted. Is there any way to do that?
Thanks
Why don't you use a MaskedTextbox? Use the following as mask, you can set the mask either at design time or at form load.
private void Form1_Load(object sender, EventArgs e)
{
maskedTextBox1.Mask = "00.00.0000";
}
You would probably be looking at something like Ajax Masked Edit
Another way to do it would be to use a jquery plugin
You could use a MaskedTextbox that will do exactly what you describe. A DateTimePicker might be better though...