本文整理汇总了C#中System.Windows.Forms.ComboBox.FindStringExact方法的典型用法代码示例。如果您正苦于以下问题:C# ComboBox.FindStringExact方法的具体用法?C# ComboBox.FindStringExact怎么用?C# ComboBox.FindStringExact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ComboBox
的用法示例。
在下文中一共展示了ComboBox.FindStringExact方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateGroupsDropDown
public static void PopulateGroupsDropDown(ComboBox cb, string selected_text)
{
cb.Items.Clear();
dbGroups.Read();
foreach (Database.GroupDetails gd in dbGroups.ArrayListGroups)
{
cb.Items.Add(gd.GroupName);
}
cb.Items.Add("( Add new Group ) ...");
if (selected_text != string.Empty)
{
cb.SelectedIndex = cb.FindStringExact(selected_text);
}
}
示例2: SetDetails
private static void SetDetails(ComboBox cbo, string details)
{
if (string.IsNullOrEmpty(details))
cbo.SelectedIndex = -1;
else
{
int index = cbo.FindStringExact(details);
if (index >= 0 || cbo.DropDownStyle == ComboBoxStyle.DropDownList)
cbo.SelectedIndex = index;
cbo.Text = details;
}
}
示例3: FindStringExact_StartIndex_Max
public void FindStringExact_StartIndex_Max ()
{
ComboBox cmbbox = new ComboBox ();
cmbbox.Items.AddRange (new object [] { "ACBD", "ABDC", "ACBD", "ABCD" });
try {
cmbbox.FindStringExact ("Hola", 4);
Assert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsNotNull (ex.ParamName, "#5");
Assert.AreEqual ("startIndex", ex.ParamName, "#6");
}
}
示例4: FindStringExact_StartIndex_ItemCount
public void FindStringExact_StartIndex_ItemCount ()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo ("tr-TR");
ComboBox cmbbox = new ComboBox ();
cmbbox.Items.AddRange (new object [] { "AB", "BA", "AB", "BA" });
#if NET_2_0
Assert.AreEqual (1, cmbbox.FindStringExact ("BA", 3));
#else
try {
cmbbox.FindString ("BA", 3);
Assert.Fail ("#1");
} catch (ArgumentOutOfRangeException ex) {
Assert.AreEqual (typeof (ArgumentOutOfRangeException), ex.GetType (), "#2");
Assert.IsNull (ex.InnerException, "#3");
Assert.IsNotNull (ex.Message, "#4");
Assert.IsNotNull (ex.ParamName, "#5");
Assert.AreEqual ("startIndex", ex.ParamName, "#6");
}
#endif
}
示例5: FindStringExact
public void FindStringExact ()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo ("tr-TR");
ComboBox cmbbox = new ComboBox ();
Assert.AreEqual (-1, cmbbox.FindStringExact ("Hello"), "#A1");
Assert.AreEqual (-1, cmbbox.FindStringExact (string.Empty), "#A2");
Assert.AreEqual (-1, cmbbox.FindStringExact (null), "#A3");
Assert.AreEqual (-1, cmbbox.FindStringExact ("Hola", -5), "#A4");
Assert.AreEqual (-1, cmbbox.FindStringExact ("Hola", 40), "#A5");
cmbbox.Items.AddRange (new object [] { "in", "BADTest", "IN", "BAD", "Bad", "In" });
Assert.AreEqual (2, cmbbox.FindStringExact ("IN"), "#B1");
Assert.AreEqual (0, cmbbox.FindStringExact ("in"), "#B2");
Assert.AreEqual (3, cmbbox.FindStringExact ("BAD"), "#B3");
Assert.AreEqual (3, cmbbox.FindStringExact ("bad"), "#B4");
Assert.AreEqual (-1, cmbbox.FindStringExact ("B"), "#B5");
Assert.AreEqual (-1, cmbbox.FindStringExact ("NonExistant"), "#B6");
Assert.AreEqual (-1, cmbbox.FindStringExact (string.Empty), "#B7");
Assert.AreEqual (-1, cmbbox.FindStringExact (null), "#B8");
Assert.AreEqual (2, cmbbox.FindStringExact ("In", 1), "#C1");
Assert.AreEqual (5, cmbbox.FindStringExact ("In", 2), "#C2");
Assert.AreEqual (4, cmbbox.FindStringExact ("BaD", 3), "#C3");
Assert.AreEqual (3, cmbbox.FindStringExact ("bad", -1), "#C4");
Assert.AreEqual (5, cmbbox.FindStringExact ("In", 4), "#C5");
Assert.AreEqual (3, cmbbox.FindStringExact ("bad", 4), "#C6");
Assert.AreEqual (-1, cmbbox.FindStringExact ("B", 4), "#C7");
Assert.AreEqual (-1, cmbbox.FindStringExact ("BADNOT", 0), "#C8");
Assert.AreEqual (-1, cmbbox.FindStringExact ("i", -1), "#C9");
Assert.AreEqual (-1, cmbbox.FindStringExact (string.Empty, 2), "#C10");
Assert.AreEqual (-1, cmbbox.FindStringExact (null, 1), "#C11");
cmbbox.Items.Add (string.Empty);
Assert.AreEqual (6, cmbbox.FindStringExact (string.Empty), "#D1");
Assert.AreEqual (-1, cmbbox.FindStringExact (null), "#D2");
Assert.AreEqual (6, cmbbox.FindStringExact (string.Empty, 3), "#E1");
Assert.AreEqual (-1, cmbbox.FindStringExact (null, 99), "#E2");
Assert.AreEqual (-1, cmbbox.FindStringExact (null, -5), "#E3");
}
示例6: UpdataMainPropBindValue
private void UpdataMainPropBindValue(ComboBox MModel, TextBox MPropRadius, TextBox MPropResolutin, int PropagModelId, string radius, string resolution)
{
if (PropagModelId == -1)
{
MModel.SelectedIndex = 0;
MPropRadius.Text = "0";
MPropResolutin.Text = "0";
}
else
{
MModel.SelectedIndex = MModel.FindStringExact(this.m_TplRelayModule.GetPropNameByID(PropagModelId));
MPropRadius.Text = radius;
if (MPropRadius.Text == string.Empty)
{
MPropRadius.Text = "0";
}
MPropResolutin.Text = resolution;
if (MPropResolutin.Text == string.Empty)
{
MPropResolutin.Text = "0";
}
}
}
示例7: FindStringExact_StartIndex_ItemCount
public void FindStringExact_StartIndex_ItemCount ()
{
Thread.CurrentThread.CurrentCulture = new CultureInfo ("tr-TR");
ComboBox cmbbox = new ComboBox ();
cmbbox.Items.AddRange (new object [] { "AB", "BA", "AB", "BA" });
Assert.AreEqual (1, cmbbox.FindStringExact ("BA", 3));
}
示例8: AutoCompleteOnKeyPress
/// <summary>
/// Autocomplete a combobox on keypress
/// </summary>
/// <param name="comboBox"></param>
/// <param name="e"></param>
public static void AutoCompleteOnKeyPress(ComboBox comboBox, KeyPressEventArgs e)
{
if (Char.IsControl(e.KeyChar))
return;
string stringToFind = comboBox.Text.Substring(0, comboBox.SelectionStart) + e.KeyChar;
int index = comboBox.FindStringExact(stringToFind);
if (index == -1)
index = comboBox.FindString(stringToFind);
if (index == -1)
return;
comboBox.SelectedIndex = index;
comboBox.SelectionStart = stringToFind.Length;
comboBox.SelectionLength = comboBox.Text.Length - comboBox.SelectionStart;
e.Handled = true;
}
示例9: UseItem
private void UseItem(string Item, ComboBox ComboBox)
{
ComboBox.SelectedIndex = ComboBox.FindStringExact(Item);
}
示例10: ReadFromFileEDIT
//Добавление новой записи
//Чтение из файла с выводом в конкретные поля
public void ReadFromFileEDIT(int ID,TextBox textname, TextBox textname2, TextBox textname3, DateTimePicker date, TextBox phone, TextBox addinfo, ComboBox whois, PictureBox photo, TextBox adress, TextBox email, NumericUpDown dal, NumericUpDown vz9l)
{
OleDbConnection con = new OleDbConnection("provider=Microsoft.Jet.OleDb.4.0;Data Source=" + DBpath + ";Jet OLEDB:Database Password=" + DBpass + ";");
OleDbCommand cmd = new OleDbCommand();
cmd.Connection = con;
cmd.CommandText = "Select ID,Имя, Фамилия, Отчество, Дата_Рождения, Телефон, Адресс, Email, Кем_Является, Доп_Информация, Взял_В_Займы, Дал_В_Займы, Фото from People";
con.Open();
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
int currentid = Convert.ToInt32(dr["ID"]);
if (currentid == ID)
{
textname.Text = dr["Имя"].ToString();
textname2.Text = dr["Фамилия"].ToString();
textname3.Text = dr["Отчество"].ToString();
date.Value = Convert.ToDateTime(dr["Дата_Рождения"]);
phone.Text = dr["Телефон"].ToString();
adress.Text = dr["Адресс"].ToString();
email.Text = dr["Email"].ToString();
whois.SelectedIndex = whois.FindStringExact(dr["Кем_Является"].ToString());
addinfo.Text = dr["Доп_Информация"].ToString();
vz9l.Value = Convert.ToDecimal(dr["Взял_В_Займы"]);
dal.Value =Convert.ToDecimal(dr["Дал_В_Займы"]);
photo.Image = null;
if (dr["Фото"] != DBNull.Value)
{
photo_aray = (byte[])dr["Фото"];
MemoryStream ms = new MemoryStream(photo_aray);
photo.Image = Image.FromStream(ms);
}
}
}
con.Close();
}
示例11: FillCombo
private void FillCombo(ComboBox c, object[] p)
{
string old = "";
if (c.SelectedIndex >= 0) old = c.Items[c.SelectedIndex].ToString();
c.Items.Clear();
c.Items.AddRange(p);
if (old != "") c.SelectedIndex = c.FindStringExact(old);
c.Enabled = true;
}
示例12: TrySelectItem
private void TrySelectItem(ComboBox cbo, string value)
{
int i = cbo.FindStringExact(value);
if (i >= 0)
cbo.SelectedIndex = i;
}
示例13: UpdataMainPropBindValue
private void UpdataMainPropBindValue(ComboBox MModel, TextBox MPropRadius, TextBox MPropResolutin, int propagModelID, string radius, string resolution)
{
int num = this.m_TemplateTransceiverModule.TDTemplateCellModule.getPropModelMainID();
if (propagModelID == -1)
{
MModel.SelectedIndex = 0;
MPropRadius.Text = "0";
MPropResolutin.Text = "0";
}
else
{
MModel.SelectedIndex = MModel.FindStringExact(this.m_TemplateTransceiverModule.GetPropNameByID(propagModelID));
MPropRadius.Text = radius;
if (MPropRadius.Text == string.Empty)
{
MPropRadius.Text = "0";
}
MPropResolutin.Text = resolution;
if (MPropResolutin.Text == string.Empty)
{
MPropResolutin.Text = "0";
}
}
}
示例14: InitialSelectCb
public static void InitialSelectCb(ComboBox cb, string Seleccion)
{
cb.SelectedIndex=cb.FindStringExact(Seleccion);
}
示例15: createCustomField
private void createCustomField(RedmineSettings.CustomFieldDefinition definition, int index) {
//Window
this.Size = new System.Drawing.Size(this.Size.Width, this.Size.Height + customFieldHeight);
//New Issues
this.issueDescription.Size = new System.Drawing.Size(this.issueDescription.Size.Width, this.issueDescription.Size.Height - customFieldHeight );
Label newIssueLabel = new System.Windows.Forms.Label();
newIssueLabel.AutoSize = true;
newIssueLabel.Location = new System.Drawing.Point(8, currentCustomFieldPositionNewIssue);
newIssueLabel.Size = new System.Drawing.Size(52, 13);
newIssueLabel.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))));
newIssueLabel.Text = string.Concat(definition.name, ":");
this.tabPage1.Controls.Add(newIssueLabel);
if (definition.fieldtype == RedmineSettings.CustomFieldDefinition.Fieldtype.FieldTypeList) {
ComboBox newInputElement = new System.Windows.Forms.ComboBox();
newInputElement.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
newInputElement.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
newInputElement.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
newInputElement.FormattingEnabled = true;
newInputElement.Location = new System.Drawing.Point(65, currentCustomFieldPositionNewIssue);
newInputElement.Size = new System.Drawing.Size(479, 21);
newInputElement.Items.AddRange(definition.values);
if (!definition.defaultValue.Equals("")) {
newInputElement.SelectedIndex = newInputElement.FindStringExact(definition.defaultValue);
}
this.tabPage1.Controls.Add(newInputElement);
customFieldsNew[index] = newInputElement;
} else {
TextBox newInputElement = new System.Windows.Forms.TextBox();
newInputElement.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
newInputElement.Location = new System.Drawing.Point(65, currentCustomFieldPositionNewIssue);
newInputElement.Size = new System.Drawing.Size(479, 20);
newInputElement.Text = definition.defaultValue;
this.tabPage1.Controls.Add(newInputElement);
customFieldsNew[index] = newInputElement;
}
currentCustomFieldPositionNewIssue += customFieldHeight;
//Update Issues
this.issueNote.Size = new System.Drawing.Size(this.issueNote.Size.Width, this.issueNote.Size.Height - customFieldHeight );
Label updateIssueLabel = new System.Windows.Forms.Label();
updateIssueLabel.AutoSize = true;
updateIssueLabel.Location = new System.Drawing.Point(8, currentCustomFieldPositionUpdateIssue);
updateIssueLabel.Size = new System.Drawing.Size(52, 13);
updateIssueLabel.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))));
updateIssueLabel.Text = string.Concat(definition.name, ":");
this.tabPage2.Controls.Add(updateIssueLabel);
if (definition.fieldtype == RedmineSettings.CustomFieldDefinition.Fieldtype.FieldTypeList) {
ComboBox updateInputElement = new System.Windows.Forms.ComboBox();
updateInputElement.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
updateInputElement.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
updateInputElement.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
updateInputElement.FormattingEnabled = true;
updateInputElement.Location = new System.Drawing.Point(65, currentCustomFieldPositionUpdateIssue);
updateInputElement.Size = new System.Drawing.Size(479, 21);
updateInputElement.Items.AddRange(definition.values);
this.tabPage2.Controls.Add(updateInputElement);
customFieldsUpdate[index] = updateInputElement;
} else {
TextBox updateInputElement = new System.Windows.Forms.TextBox();
updateInputElement.Anchor =
((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right)));
updateInputElement.Location = new System.Drawing.Point(65, currentCustomFieldPositionUpdateIssue);
updateInputElement.Size = new System.Drawing.Size(479, 20);
this.tabPage2.Controls.Add(updateInputElement);
customFieldsUpdate[index] = updateInputElement;
}
currentCustomFieldPositionUpdateIssue += customFieldHeight;
/*
this.issueNote = new System.Windows.Forms.TextBox();
//
// issueNote
//
this.issueNote.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.issueNote.Location = new System.Drawing.Point(9, 238);
this.issueNote.Multiline = true;
this.issueNote.Name = "issueNote";
this.issueNote.Size = new System.Drawing.Size(526, 65);
this.issueNote.TabIndex = 15;
this.tabPage2.Controls.Add(this.issueNote);
;*/
}