本文整理汇总了C#中System.Windows.Controls.TextBox.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# TextBox.Clear方法的具体用法?C# TextBox.Clear怎么用?C# TextBox.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.TextBox
的用法示例。
在下文中一共展示了TextBox.Clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CalculateLoadScheme
public List<Container> CalculateLoadScheme(List<Container> containers,
ObservableCollection<Vehicle> selectedVehicles, TextBox textBox, int maxTonnage)
{
// BtnCalculate_click
int tempMaxTonnage;
var widthBetweenVehicles = 1000;
var tempPoint = new Point3D(0, 0, 0);
textBox.Clear();
textBox.AppendText("Протокол расчета схемы загрузки:\n");
var tempList = RotateContainers(containers);
foreach (var vehicle in selectedVehicles)
{
LocateContainers locateContainers = new LocateContainers(vehicle);
tempMaxTonnage = maxTonnage == 0 ? vehicle.Tonnage : maxTonnage;
tempList = locateContainers.DownloadContainers(tempList, tempMaxTonnage);
SetFirstPoint(tempPoint,vehicle);
tempPoint.Y = tempPoint.Y + widthBetweenVehicles + vehicle.Width;// TODO tempPoint.Z = tempPoint.Z + widthBetweenVehicles + vehicle.Width;
PutCargoInfoInTextBox(vehicle, textBox);
CheckOverweight(vehicle, textBox, tempMaxTonnage);
VehicleAxisMass vehicleAxisMass = new VehicleAxisMass(vehicle, vehicle.Mass);
PutVehAxisMassInfoInTextBox(vehicleAxisMass.AxisMassCalculate(), textBox);
}
PutWasteContainersInfoInTextBox(tempList, textBox);
CheckErrors(tempList, textBox, selectedVehicles, containers);
return tempList;
}
示例2: Limpiar
public static void Limpiar(TextBox t1, TextBox t2 = null, TextBox t3 = null)
{
t1.Clear();
if (t2 != null)
t2.Clear();
if (t3 != null)
t3.Clear();
t1.Focus();
}
示例3: bin
//DEC TO BIN
private void bin(int dec, TextBox text)
{
text.Clear();
for(int i=15;i>=0;i--)
{
if (i == 7) text.Text += " ";
text.Text += Convert.ToString((dec >> i) % 2);
}
}
示例4: checkNumBox
void checkNumBox(TextBox box)
{
int convertedText = 0;
if (!int.TryParse(box.Text, out convertedText))
{
box.Clear();
}
}
示例5: ButtonCode
public void ButtonCode(int GBATotal, int NDSTotal, bool GBA, bool NDS, TextBox ButtonInput, TextBox ButtonOutput, TextBox NDSTst, TextBox GBATst)
{
//NOT_GBA and NOT_NDS will hold the
//16-bit values of NOT_GBATotal and NOT_NDSTotal
string D2 = "D2000000 00000000";
ushort NOT_GBA = (ushort)~GBATotal;
ushort NOT_NDS = (ushort)~NDSTotal;
if (GBATotal != 0)
GBA = true;
if (NDSTotal != 0)
NDS = true;
if (GBA == true)
{
ButtonOutput.Text = "94000130 " + NOT_GBA.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2;
GBATst.Text = "GBA tst Value: 0x" + GBATotal.ToString("X4");
}
else GBATst.Clear();
if (NDS == true)
{
ButtonOutput.Text = "927FFFA8 " + NOT_NDS.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2;
NDSTst.Text = "NDS tst Value: 0x" + NDSTotal.ToString("X4");
}
else NDSTst.Clear();
if (GBA == true && NDS == true)
{
ButtonOutput.Text = "927FFFA8 " + NOT_NDS.ToString("X") + "0000\n94000130 " +
NOT_GBA.ToString("X") + "0000\n" + ButtonInput.Text + '\n' + D2;
}
else if (GBA == false && NDS == false)
{
ButtonOutput.Clear();
GBATst.Clear();
NDSTst.Clear();
}
}
示例6: checkTextBox
void checkTextBox(TextBox box)
{
if (box.Text.Intersect(forbiddenChars).Any())
{
box.Clear();
}
if (box.Text.Intersect(smallChars).Any())
{
box.Text = box.Text.ToUpper();
box.SelectionStart = box.Text.Length;
box.SelectionLength = 0;
}
}
示例7: handleTextChange
//checks whether textbox content > 255 when 3 characters have been entered.
//clears if > 255, switches to next textbox otherwise
private void handleTextChange(TextBox currentBox, TextBox rightNeighborBox)
{
if (currentBox.Text.Length == 3)
{
try
{
Convert.ToByte(currentBox.Text);
}
catch (Exception exception) when (exception is FormatException || exception is OverflowException)
{
currentBox.Clear();
currentBox.Focus();
SystemSounds.Beep.Play();
MessageBox.Show(errorMessage, "Error", MessageBoxButton.OK, MessageBoxImage.Warning);
return;
}
if (currentBox.CaretIndex != 2 && currentBox != fourthBox)
{
rightNeighborBox.CaretIndex = rightNeighborBox.Text.Length;
rightNeighborBox.SelectAll();
rightNeighborBox.Focus();
}
}
}
示例8: ApplicationCanvas
public ApplicationCanvas()
{
r.Fill = Brushes.LightGray;
r.AttachTo(this);
r.MoveTo(4, 4);
this.SizeChanged += (s, e) => r.SizeTo(this.Width - 8.0, this.Height - 8.0);
var label1 = new TextBlock
{
Text = "Enter a list of names separated by commas",
}.AttachTo(this).MoveTo(8, 8);
var users = new TextBox
{
AcceptsReturn = true,
TextWrapping = System.Windows.TextWrapping.Wrap,
Width = 500,
Height = 50,
Text = "_martin, mike, mac, ken, neo, zen, jay, morpheous, trinity, Agent Smith, _psycho",
}.AttachTo(this).MoveTo(8, 8 + 32);
var label2 = new TextBlock
{
Text = "Enter a partial name to be found from the list above.",
}.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8);
var filter = new TextBox
{
Width = 500,
Text = "psy",
}.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16);
var label3 = new TextBlock
{
Text = "Enter a partial name to make the entry special",
}.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58);
var filter2 = new TextBox
{
Width = 500,
Text = "a",
}.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58);
var label4 = new TextBlock
{
Text = "Results",
}.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 58 + 58);
var result = new TextBox
{
AcceptsReturn = true,
TextWrapping = System.Windows.TextWrapping.Wrap,
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
Width = 500,
Height = 50,
Text = "?",
TextAlignment = System.Windows.TextAlignment.Right,
IsReadOnly = true,
}.AttachTo(this).MoveTo(8, 8 + 32 + 50 + 8 + 16 + 58 + 58);
Action Update =
delegate
{
var user_filter = filter.Text.Trim().ToLower();
var user_filter2 = filter2.Text.Trim().ToLower();
result.Clear();
var __users = users.Text.Split(',');
var query = from i in __users
where i.ToLower().Contains(user_filter)
let name = i.Trim()
let isspecial = i.ToLower().Contains(user_filter2)
orderby isspecial ascending, name.Length descending, name
select new { isspecial, length = name.Length, name };
foreach (var v in query)
{
var m = "match: " + v;
if (v.isspecial)
m = m.ToUpper();
result.AppendText(m + Environment.NewLine);
}
};
Update();
users.TextChanged += delegate { Update(); };
filter.TextChanged += delegate { Update(); };
//.........这里部分代码省略.........
示例9: checkLanguage
bool checkLanguage(TextBox box)
{
bool result = true;
if (language == Alphabet.English)
{
if (box.Text.Intersect(Cezar.ALPHABET_RU).Any())
{
box.Clear();
result = false;
}
}
if (language == Alphabet.Russian)
{
if (box.Text.Intersect(Cezar.ALPHABET_EN).Any())
{
box.Clear();
result = false;
}
}
return result;
}
示例10: printToBox
void printToBox(TextBox box, int[] array)
{
box.Clear();
foreach (byte num in array)
{
//if (num == 0) continue;
box.Text += num + " ";
}
}
示例11: auxRestAfterDamage
//aux function for a damage timer, its sending workers to rest
private void auxRestAfterDamage(TextBox text)
{
//during breakdown
int freePositions = Convert.ToInt32(tbNumber.Text) + 1;
load.amountWorkers = load.amountWorkers - 1;
text.IsEnabled = false;
auxFill();
tbNumber.Text = Convert.ToString(freePositions);
text.Clear();
}
示例12: ConstructObjects
private void ConstructObjects()
{
var lbStation = new Label();
lbStation.Content = "選擇站別 ( * ) :";
var bStation = new Border();
bStation.Width = 300;
bStation.Height = 40;
bStation.Background = Brushes.White;
bStation.BorderBrush = Brushes.White;
bStation.BorderThickness = new Thickness(5);
var cbstation = new ComboBox();
cbstation.Items.Add(StationName.gStationA);
cbstation.Items.Add(StationName.gStationB);
cbstation.Items.Add(StationName.gStationC);
//cbstation.Items.Add(StationName.gStationD);
cbstation.Items.Add(StationName.gStationE);
cbstation.Items.Add(StationName.gStationF);
cbstation.Items.Add(StationName.gStationG);
bStation.Child = cbstation;
cbstation.SelectionChanged += cbstation_SelectionChanged;
var spName = new StackPanel();
spName.HorizontalAlignment = HorizontalAlignment.Left;
var lbUsername = new Label();
lbUsername.Content = "操作人員 ( * ) :";
var txtboxUsername = new TextBox();
txtboxUsername.Height = 30;
txtboxUsername.Width = 150;
txtboxUsername.KeyUp += txtboxUsername_KeyUp;
spName.Children.Add(lbUsername);
spName.Children.Add(txtboxUsername);
var lbLogin = new Label();
lbLogin.Content = SigknowDBServer.gServer;
var buttonLogin = new Button();
buttonLogin.Content = "登入";
buttonLogin.Click += buttonLogin_Click;
buttonLogin.Height = 30;
buttonLogin.Width = 50;
var spServer = new StackPanel();
spServer.HorizontalAlignment = HorizontalAlignment.Left;
var lbServer = new Label();
lbServer.Content = "資料庫網址 ( * ) :";
var txtboxServer = new TextBox();
txtboxServer.Height = 30;
txtboxServer.Width = 150;
txtboxServer.KeyUp += txtboxServer_KeyUp;
var buttonServer = new Button();
buttonServer.Content = "設定";
buttonServer.Click += buttonServer_Click;
buttonServer.Height = 30;
buttonServer.Width = 50;
Utils.changeTextboxLang2Eng(txtboxServer);
var lbReport = new Label();
lbReport.Content = "";
spServer.Children.Add(lbServer);
spServer.Children.Add(txtboxServer);
var buttonReport = new Button();
buttonReport.Content = "匯出資料";
buttonReport.Click += buttonReport_Click;
buttonReport.Height = 30;
buttonReport.Width = 100;
StackPanel spMainBody = new StackPanel();
spMainBody.HorizontalAlignment = HorizontalAlignment.Left;
spMainBody.Children.Add(spServer);
spMainBody.Children.Add(buttonServer);
spMainBody.Children.Add(lbStation);
spMainBody.Children.Add(bStation);
spMainBody.Children.Add(spName);
spMainBody.Children.Add(lbLogin);
spMainBody.Children.Add(buttonLogin);
spMainBody.Children.Add(lbReport);
spMainBody.Children.Add(buttonReport);
txtboxServer.Clear();
txtboxServer.Focus();
Content = spMainBody;
}
示例13: Parse
private decimal Parse(TextBox txt)
{
decimal var;
try
{
if (!String.IsNullOrWhiteSpace(txt.Text))
{
// Try to parse param if it's not null
var = decimal.Parse(txt.Text);
}
else
{
var = 0m;
}
}
catch
{
// Clear and focus on error location. Prompt user as to where the error occurred using the ToolTip
txt.Clear();
txt.Focus();
throw new Exception("Error! Value of " + txt.ToolTip.ToString() + " required as a decimal");
}
return var;
}
示例14: Clean
public static void Clean(TextBox textbox)
{
textbox.Clear();
}
示例15: rest
//function sending workers to rest
private void rest(TextBox text)
{
int freePositions = Convert.ToInt32(tbNumber.Text) + 1;
if (text.IsEnabled == true)
{
load.amountWorkers = load.amountWorkers - 1;
text.IsEnabled = false;
auxFill();
tbNumber.Text = Convert.ToString(freePositions);
text.Clear();
}
else MessageBox.Show("This position is not filled!");
}