本文整理汇总了C#中System.Windows.Forms.CheckedListBox类的典型用法代码示例。如果您正苦于以下问题:C# CheckedListBox类的具体用法?C# CheckedListBox怎么用?C# CheckedListBox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CheckedListBox类属于System.Windows.Forms命名空间,在下文中一共展示了CheckedListBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddColumnsToCheckList
private static void AddColumnsToCheckList(CheckedListBox checkList, RowCollection rowCollection)
{
foreach (var columnHeader in rowCollection.GetColumnHeaders())
{
checkList.Items.Add(columnHeader);
}
}
示例2: DALControl
public DALControl(string dbTableName, string PascalTableName, bool isPascal, string preNS,
string preClass, string preModel,
bool isLog, CheckedListBox checkedListBox1, EnumDbType dbType)
{
this.TableName = dbTableName;
this.PascalTableName = PascalTableName;
this.IsPascal = isPascal;
this.PreNs = preNS;
this.SbTemp = new StringBuilder();
this.PreClass = preClass;
this.PreModel = preModel;
this.IsLog = isLog;
this.CheckedListBox1 = checkedListBox1;
this.DbType = dbType;
if (this.DbType == EnumDbType.Oracle)
{
dbHelper = "DbHelperOracle";
parameter = "OracleParameter";
paramsHelper = "ParamsHelperOracle";
}
else if (this.DbType == EnumDbType.SqlServer)
{
dbHelper = "DbHelperSqlServer";
parameter = "SqlParameter";
paramsHelper = "ParamsHelperSqlServer";
}
listPrimaryKey = TableControl.GetPrimayKeys(dbTableName, this.DbType);
dtColumns = ColumnControl.GetTableColumnsByTableName(dbTableName, this.DbType);
}
示例3: ValidateCheckList
public static bool ValidateCheckList(CheckedListBox boxes, ErrorProvider errorProvider)
{
if(boxes.CheckedItems.Count > 0)
return true;
errorProvider.SetError(boxes, "Este campo es obligatorio");
return false;
}
示例4: foreach
protected List<ushort>GetChecked(CheckedListBox list)
{
List<ushort> result = new List<ushort>();
foreach (var c in list.CheckedItems)
result.Add((c is Zone) ? ushort.Parse((c as Zone).Id) : (c as Terminal).ReferenceId);
return result;
}
示例5: AdvancedFilter
public void AdvancedFilter(string searchString, CheckedListBox.CheckedItemCollection checkedItems)
{
// Start from scratch
gridView.Items.Clear();
// Repopulate if empty search
if (checkedItems.Count == 0 || searchString == "")
{
fullList.ForEach(item => gridView.Items.Add(item));
return;
}
// For each video file showing:
fullList.ForEach(item =>
{
// Big Linq Statement Translation:
// - Find tag entries from file that match type of checked items
// - Any entry that contains the search string, add that file to view
var file = (VideoFile)item.Tag;
if (checkedItems.Cast<Tag>().Select(tag =>
file.Tags.Find(entry => entry.TypeId == tag.Id)).
Any(match => match != null && match.Data.ToLower().Contains(searchString.ToLower())))
{
gridView.Items.Add(item);
}
});
}
示例6: GameManager
/// <summary>
/// The GameManager constructor - responsible for
/// initialising data-fields needed by a game
/// manager object.
/// </summary>
/// <param name="charactersListBox">A CheckedListBox to hold game characters.</param>
/// <param name="battleResults">A ListBox to display the game's battle results.</param>
/// <param name="noOfPlayersInBattle">The number of players which can be in a battle.</param>
public GameManager(CheckedListBox charactersListBox, ListBox battleResults, int noOfPlayersInBattle)
{
///<summary>
///Initialising the list of game characters
///</summary>
this.characters = new List<Character>();
///<summary>
///Initialising the CheckedListBox the characters
///will be added to.
///</summary>
this.charactersListBox = charactersListBox;
///<summary>
///Initialising the ListBox which will display
///the game battle results.
///</summary>
this.battleResults = battleResults;
///<summary>
///Initialising the number of characters
///permitted in the game battle.
///</summary>
this.noOfPlayersInBattle = noOfPlayersInBattle;
}
示例7: AddElement
/// <summary>
/// add new element
/// </summary>
/// <param name="cbElements"></param>
/// <param name="clbFactsAboutElements"></param>
public void AddElement(ComboBox cbElements, CheckedListBox clbFactsAboutElements)
{
string elementName = cbElements.Text;
cbElements.Items.Add(elementName);
Dictionary<Guid, bool> factsAboutElement = new Dictionary<Guid, bool>();
foreach (var item in clbFactsAboutElements.Items)
{
RuleArgumentListBoxItem factAboutElement = item as RuleArgumentListBoxItem;
factsAboutElement.Add(factAboutElement.Id, factAboutElement.Value);
}
Guid elementId = dataAccessLayer.InsertElement(elementName, factsAboutElement);
Element element = new Element
{
Id = elementId,
Name = elementName,
Facts = factsAboutElement.Select(fae => new FactAboutElement
{
Id = fae.Key,
Value = fae.Value,
Name = inferenceModule.Facts.Find(f => f.Id == fae.Key).Name
}).ToList()
};
inferenceModule.Elements.Add(element);
}
示例8: Test_05_ChangingChannelSupportPersistsOnCommit
public void Test_05_ChangingChannelSupportPersistsOnCommit()
{
CheckedListBox edPolicySupport = new CheckedListBox();
ActionDetailController controller = new ActionDetailController();
controller.PolicySupportControl = edPolicySupport;
IResourceAction actionForTest = GetMockActionForTest();
controller.Connect(actionForTest);
List<PolicyType> policys = new List<PolicyType>(actionForTest.SupportedPolicySetting);
Assert.AreEqual(1, policys.Count, "Should start as ActiveContent and ClientEmail");
Assert.IsTrue(policys.Contains(PolicyType.ClientEmail), "Should start as ActiveContent and ClientEmail");
//get first non client email policy in list
int id = -1;
for (int i = 0; i < edPolicySupport.Items.Count; i++)
{
if (edPolicySupport.Items[i].ToString() != "Client Email Policy")
{
id = i;
break;
}
}
edPolicySupport.SetItemChecked(id, true);
policys = new List<PolicyType>(actionForTest.SupportedPolicySetting);
Assert.AreEqual(1, policys.Count, "We haven't committed anything yet");
Assert.IsTrue(policys.Contains(PolicyType.ClientEmail), "We haven't committed anything yet");
controller.Commit();
policys = new List<PolicyType>(actionForTest.SupportedPolicySetting);
Assert.AreEqual(2, policys.Count, "We haven't committed anything yet");
Assert.IsTrue(policys.Contains(PolicyType.ClientEmail), "We added ClientEmail, this should still be here");
}
示例9: EditValue
/// <inheritdoc/>
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
{
#region Sanity checks
if (context == null) throw new ArgumentNullException(nameof(context));
if (provider == null) throw new ArgumentNullException(nameof(provider));
#endregion
var languages = value as LanguageSet;
if (languages == null) throw new ArgumentNullException(nameof(value));
var editorService = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
if (editorService == null) return value;
var listBox = new CheckedListBox {CheckOnClick = true};
int i = 0;
foreach (var language in languages)
{
listBox.Items.Add(language);
listBox.SetItemChecked(i++, true);
}
foreach (var language in Languages.AllKnown.Except(languages))
listBox.Items.Add(language);
editorService.DropDownControl(listBox);
return new LanguageSet(listBox.CheckedItems.Cast<CultureInfo>());
}
示例10: LlenarChkbL_Desktop
public bool LlenarChkbL_Desktop(CheckedListBox Generico)
{
if (!Validar())
return false;
try
{
clsConexionBD objConexionBd = new clsConexionBD(strApp);
objConexionBd.SQL = strSQL;
if (!objConexionBd.LlenarDataSet(false))
{
strError = objConexionBd.Error;
objConexionBd.CerrarCnx();
objConexionBd = null;
return false;
}
Generico.DataSource = objConexionBd.DataSet_Lleno.Tables[0];
Generico.ValueMember = strCampoID;
Generico.DisplayMember = strCampoTexto;
Generico.Refresh();
objConexionBd.CerrarCnx();
objConexionBd = null;
return true;
}
catch (Exception ex)
{
strError = ex.Message;
return false;
}
}
示例11: GetSelectedItems
public static TextPackage[] GetSelectedItems(CheckedListBox listBox, List<TextPackage> licenseCaptions)
{
List<TextPackage> packs = new List<TextPackage>();
foreach (int index in listBox.CheckedIndices)
packs.Add(licenseCaptions[index]);
return packs.ToArray();
}
示例12: GetStudentUserListByYear
/// <summary>
/// GetStudentUserListByYear take StudentByYear sorted list created in the main program and the student years checkedlistbox and creates a hashtable
/// that will be used to look up the user list to display in the combolistbox display.
/// This does not use wmi service, but is the logical place add this method.
/// </summary>
/// <param name="slIn"></param>
/// <param name="checkListBox"></param>
/// <returns>sortlist</returns>
public Hashtable GetStudentUserListByYear(SortedList slIn, CheckedListBox checkListBox)
{
Hashtable ht = new Hashtable();
try
{
foreach (object itemChecked in checkListBox.CheckedItems)
{
ICollection keys = slIn.GetKeyList();
foreach (string s in keys)
{
if (s == itemChecked.ToString())
{
//this is the sortedlist of students for a given year
IList values = ((SortedList)slIn[s]).GetValueList();
//create the hashtable entries available students - this will be used to lookup and match students by year
foreach (string name in values)
{
ht.Add(name.ToUpper(), name.ToUpper());
}
}
}
}
}
catch (Exception e)
{
//re-throw exception for main calling
throw new Exception("WMIPropertiesHelper", e);
}
return (ht);
}
示例13: CheckAll
/// <summary>
/// Checks all.
/// </summary>
/// <param name="cb">The cb.</param>
/// <param name="value">if set to <c>true</c> [value].</param>
public static void CheckAll(CheckedListBox cb, bool value)
{
for (var a = 0; a < cb.Items.Count; a++)
{
cb.SetItemChecked(a, value);
}
}
示例14: clearItemCheckList
public static void clearItemCheckList(CheckedListBox check)
{
for (int item = 0; item < check.Items.Count; item++)
{
check.SetItemChecked(item, false);
}
}
示例15: llenarFuncionalidadesDeRol
public static void llenarFuncionalidadesDeRol(CheckedListBox chkLstBox, String nombreRol)
{
chkLstBox.Items.Clear();
bool activo;
try
{
using (SqlConnection conn = new SqlConnection(main.connString))
using (SqlCommand cmd = new SqlCommand())
{
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "BONDIOLA.funcionalidades_asignadas_a_rol";
cmd.Parameters.Add(new SqlParameter("@nombreRol", nombreRol));
conn.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
activo = true;
if (String.Equals(rdr["Activo"], "0"))
{
activo = false;
}
chkLstBox.Items.Add((string)rdr["nombre_funcionalidad"], activo);
}
}
}
catch (SqlException ex)
{
MessageBox.Show(ex.Message);
}
}