本文整理汇总了C#中System.Windows.Forms.Label.Focus方法的典型用法代码示例。如果您正苦于以下问题:C# Label.Focus方法的具体用法?C# Label.Focus怎么用?C# Label.Focus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.Label
的用法示例。
在下文中一共展示了Label.Focus方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImportMasters
/// <summary>
/// Imports masters tapes from file.
/// </summary>
/// <param name="worker">The worker.</param>
/// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
private void ImportMasters(BackgroundWorker worker, DoWorkEventArgs e)
{
Stream importStream = null;
//Master List import, has a popup to enter Master Tape to add to
List<MasterListValues> masterListValues = DataBaseControls.GetAllMasterListItems();
string[] cameraValues = commonMethod.CameraDropdownItems();
string masterTapeName = "";
string cameraMasterName = "";
bool addMasters = false;
//create a new form for user to enter tape name
Form masterPrompt = new Form();
masterPrompt.Height = 200;
masterPrompt.Width = 500;
masterPrompt.SizeGripStyle = SizeGripStyle.Hide;
masterPrompt.FormBorderStyle = FormBorderStyle.FixedSingle;
masterPrompt.StartPosition = FormStartPosition.CenterScreen;
masterPrompt.Text = "Enter Tape Name";
//Set up items to add to popup box
Label textLabel = new Label() { Left = 50, Top = 20, Text = "Master Archive to Import" };
ComboBox inputBox = new ComboBox() { Left = 50, Top = 50, Width = 400 };
//add items to combobox
foreach (MasterListValues values in masterListValues)
{
inputBox.Items.Add(values.MasterArchive);
}
inputBox.SelectedIndex = 0;
//add media combobox
ComboBox mediaCombo = new ComboBox() { Left = 50, Top = 75, Width = 200 };
//add items to combobox
foreach (string mediaValue in cameraValues)
{
mediaCombo.Items.Add(mediaValue);
}
mediaCombo.SelectedIndex = 1;
mediaCombo.KeyPress += (senderCombo, eCombo) => { eCombo.Handled = true; };
mediaCombo.SelectedIndexChanged += (senderCombo, eCombo) => { textLabel.Focus(); };
//Check for names in the filename
#region Check for names in File
try
{
//check to make sure there is something selected
if (!ofd.FileName.Equals(string.Empty))
{
//get name of file without extension
string nameFile = Path.GetFileNameWithoutExtension(ofd.FileName);
//get index of the word master
int index = nameFile.ToLower().IndexOf("master");
if(index != -1)
{
//get substring to include "master ddd"
nameFile = nameFile.Substring(index);
//check to make sure the last character is a digit
while (!char.IsDigit(nameFile[nameFile.Length - 1]))
{
nameFile = nameFile.Remove(nameFile.Length - 1, 1);
}
//convert name to lowercasse and then camelcase
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
nameFile = textInfo.ToTitleCase(nameFile.ToLower());
//add name of master tape if not included
if (!inputBox.Items.Contains(nameFile))
{
inputBox.Items.Add(nameFile);
}
inputBox.Text = nameFile;
}
}
}
catch { Debug.WriteLine("Error in master gather"); }
//check if there is a media defined in the name using all combobox items
try
{
//check to make sure there is something selected
if (!ofd.FileName.Equals(string.Empty))
{
//get name of file without extension
foreach (string obj in mediaCombo.Items)
{
Debug.WriteLine("In media for loop");
if (!obj.ToLower().Equals("other"))
{
Debug.WriteLine("Does not equal other");
//string[] mediaItems = mediaCombo.DataSource.t
string nameFile = Path.GetFileNameWithoutExtension(ofd.FileName);
//get index of the word master
int index = nameFile.ToLower().IndexOf(obj.ToLower());
//.........这里部分代码省略.........
示例2: lbNoteName_MouseDown
private void lbNoteName_MouseDown(object sender, MouseEventArgs e)
{
lbNameChoose = (Label)sender;
xNote = e.X;
yNote = e.Y;
xNoteMove = lbNameChoose.Left;
yNoteMove = lbNameChoose.Top;
lbNameChoose.Focus();
}
示例3: OneClickComboBoxCell
public void OneClickComboBoxCell ()
{
Form form = null;
try
{
// Create a form, a text label, and a data-grid-view.
form = new Form ();
Label label = new Label ();
label.Text = "Label";
label.Parent = form;
ClickableDataGridView dgv = new ClickableDataGridView ();
dgv.Parent = form;
// Create a combo-box column.
DataGridViewComboBoxColumn cbCol = new DataGridViewComboBoxColumn ();
cbCol.HeaderText = "Name";
dgv.Columns.Add (cbCol);
// .NET requires that all possible values for combo-boxes
// in a column are added to the column.
cbCol.Items.Add ("Item1");
cbCol.Items.Add ("Item2");
cbCol.Items.Add ("Item3");
cbCol.Items.Add ("Item4");
// Set up the contents of the data-grid.
dgv.Rows.Add ("Item1");
dgv.Rows.Add ("Item2");
// Select the cell.
dgv.CurrentCell = dgv.Rows[0].Cells[0];
// Focus the data-grid-view. (Without this, its Leave
// event won't get called when something outside of the
// data-grid-view gets focused.)
dgv.Focus ();
// Show the form, let it draw.
form.Show ();
Application.DoEvents ();
// Locate the drop-down button. (This code is taken from mono-winforms,
// from the private method DataGridViewComboBoxCell.CalculateButtonArea(),
// and was then hacked mercilessly.)
Rectangle button_area = Rectangle.Empty;
{
int border = 3 /* ThemeEngine.Current.Border3DSize.Width */;
const int button_width = 16;
Rectangle text_area = dgv.GetCellDisplayRectangle (0, 0, false);
button_area.X = text_area.Right - button_width - border;
button_area.Y = text_area.Y + border;
button_area.Width = button_width;
button_area.Height = text_area.Height - 2 * border;
}
// Click on the drop-down button.
int x = button_area.X + (button_area.Width / 2);
int y = button_area.Y + (button_area.Height / 2);
if (Environment.OSVersion.Platform == PlatformID.Win32NT
&& Type.GetType ("Mono.Runtime") == null)
{
// Calling OnMouseDownInternal () in Win32 doesn't work.
// My best guess as to why is that the WinForms ComboBox
// is a wrapper around the ComCtl control, e.g. similar
// to the reason that Paint event-handlers don't work on
// TreeView. So we go through all this rigamarole to
// simulate a mouse click.
// First, get the location of the desired mouse-click, in
// data-grid-view coordinates.
Win32Point ptGlobal = new Win32Point ();
ptGlobal.x = x + dgv.Location.X;
ptGlobal.y = y + dgv.Location.Y;
// Convert that to screen coordinates.
ClientToScreen (form.Handle, ref ptGlobal);
// Move the mouse-pointer there. (Yes, this really appears
// to be necessary.)
SetCursorPos (ptGlobal.x, ptGlobal.y);
// Convert screen coordinates to mouse coordinates.
ptGlobal.x *= (65535 / SystemInformation.VirtualScreen.Width);
ptGlobal.y *= (65535 / SystemInformation.VirtualScreen.Height);
// Finally, fire a mouse-down and mouse-up event.
mouse_event (MOUSEEVENTF_LEFTDOWN|MOUSEEVENTF_ABSOLUTE,
ptGlobal.x, ptGlobal.y, 0, 0);
mouse_event (MOUSEEVENTF_LEFTUP|MOUSEEVENTF_ABSOLUTE,
ptGlobal.x, ptGlobal.y, 0, 0);
// Let the system process these events.
Application.DoEvents ();
}
else
{
// And this is how the same code is done under Linux.
// (No one should wonder why I prefer Mono to MS Windows .NET ;-)
MouseEventArgs me = new MouseEventArgs (MouseButtons.Left, 1, x, y, 0);
//.........这里部分代码省略.........
示例4: SeleccionarImagen
/// <summary>
/// Seleccionar una imagen dentro del componente, a partir del nombre de la misma
/// </summary>
/// <param name="pRutaImagen"></param>
public void SeleccionarImagen( string pRutaImagen)
{
int mIndice = -1;
for (int i = 0; i < this.ListaImagenes.Count; i++)
if (this.ListaImagenes.ElementAt(i).ToLower() == pRutaImagen.ToLower())
mIndice = i;
if (mIndice >= 0)
{
DeseleccionarImagen();
iPBoxSeleccionado = (PictureBox)this.Controls.Find("PictureBox" + mIndice.ToString() , true)[0];
iPBoxSeleccionado.Focus();
if (this.labels)
{
iLabelSeleccionado = (Label)this.Controls.Find("LabelPictureBox" + mIndice.ToString(), true)[0];
iLabelSeleccionado.BackColor = Color.Firebrick;
iLabelSeleccionado.Focus();
}
}
}