Click here to Skip to main content
15,896,153 members
Articles / Programming Languages / C#

Fully data-bound CheckedListBox

Rate me:
Please Sign up or sign in to vote.
4.69/5 (16 votes)
19 Apr 2008CPOL3 min read 80.2K   2K   32  
BoundCheckedListBox is bindable to three tables representing a many-to-many data relation.
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="manytomanyDataSet" targetNamespace="http://tempuri.org/manytomanyDataSet.xsd" xmlns:mstns="http://tempuri.org/manytomanyDataSet.xsd" xmlns="http://tempuri.org/manytomanyDataSet.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:msprop="urn:schemas-microsoft-com:xml-msprop" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:annotation>
    <xs:appinfo source="urn:schemas-microsoft-com:xml-msdatasource">
      <DataSource DefaultConnectionIndex="0" FunctionsComponentName="QueriesTableAdapter" Modifier="AutoLayout, AnsiClass, Class, Public" SchemaSerializationMode="IncludeSchema" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
        <Connections>
          <Connection AppSettingsObjectName="Settings" AppSettingsPropertyName="manytomanyConnectionString" ConnectionStringObject="" IsAppSettingsProperty="True" Modifier="Assembly" Name="manytomanyConnectionString (Settings)" PropertyReference="ApplicationSettings.manytomanytest.Properties.Settings.GlobalReference.Default.manytomanyConnectionString" Provider="System.Data.OleDb">
          </Connection>
        </Connections>
        <Tables>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="FruechteTableAdapter" GeneratorDataComponentClassName="FruechteTableAdapter" Name="Fruechte" UserDataComponentName="FruechteTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="manytomanyConnectionString (Settings)" DbObjectName="Fruechte" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="True" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="True" UserGetMethodName="GetData" UserSourceName="Fill">
                <DeleteCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>DELETE FROM `Fruechte` WHERE ((`ID` = ?) AND ((? = 1 AND `Name` IS NULL) OR (`Name` = ?)))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_Name" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="True" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Original_Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </DeleteCommand>
                <InsertCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>INSERT INTO `Fruechte` (`ID`, `Name`) VALUES (?, ?)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </InsertCommand>
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>SELECT ID, Name FROM Fruechte</CommandText>
                    <Parameters>
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
                <UpdateCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>UPDATE `Fruechte` SET `ID` = ?, `Name` = ? WHERE ((`ID` = ?) AND ((? = 1 AND `Name` IS NULL) OR (`Name` = ?)))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_Name" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="True" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Original_Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </UpdateCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="ID" DataSetColumn="ID" />
              <Mapping SourceColumn="Name" DataSetColumn="Name" />
            </Mappings>
            <Sources>
            </Sources>
          </TableAdapter>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="p_fTableAdapter" GeneratorDataComponentClassName="p_fTableAdapter" Name="p_f" UserDataComponentName="p_fTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="manytomanyConnectionString (Settings)" DbObjectName="p_f" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="True" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="True" UserGetMethodName="GetData" UserSourceName="Fill">
                <InsertCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>INSERT INTO `p_f` (`pID`, `fID`) VALUES (?, ?)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="pID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="pID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="fID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="fID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </InsertCommand>
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>SELECT pID, fID FROM p_f</CommandText>
                    <Parameters>
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="pID" DataSetColumn="pID" />
              <Mapping SourceColumn="fID" DataSetColumn="fID" />
            </Mappings>
            <Sources>
            </Sources>
          </TableAdapter>
          <TableAdapter BaseClass="System.ComponentModel.Component" DataAccessorModifier="AutoLayout, AnsiClass, Class, Public" DataAccessorName="PersonenTableAdapter" GeneratorDataComponentClassName="PersonenTableAdapter" Name="Personen" UserDataComponentName="PersonenTableAdapter">
            <MainSource>
              <DbSource ConnectionRef="manytomanyConnectionString (Settings)" DbObjectName="Personen" DbObjectType="Table" FillMethodModifier="Public" FillMethodName="Fill" GenerateMethods="Both" GenerateShortCommands="True" GeneratorGetMethodName="GetData" GeneratorSourceName="Fill" GetMethodModifier="Public" GetMethodName="GetData" QueryType="Rowset" ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" UseOptimisticConcurrency="True" UserGetMethodName="GetData" UserSourceName="Fill">
                <DeleteCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>DELETE FROM `Personen` WHERE ((`ID` = ?) AND ((? = 1 AND `Name` IS NULL) OR (`Name` = ?)))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_Name" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="True" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Original_Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </DeleteCommand>
                <InsertCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>INSERT INTO `Personen` (`ID`, `Name`) VALUES (?, ?)</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </InsertCommand>
                <SelectCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>SELECT ID, Name FROM Personen</CommandText>
                    <Parameters>
                    </Parameters>
                  </DbCommand>
                </SelectCommand>
                <UpdateCommand>
                  <DbCommand CommandType="Text" ModifiedByUser="False">
                    <CommandText>UPDATE `Personen` SET `ID` = ?, `Name` = ? WHERE ((`ID` = ?) AND ((? = 1 AND `Name` IS NULL) OR (`Name` = ?)))</CommandText>
                    <Parameters>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Current">
                      </Parameter>
                      <Parameter AllowDbNull="False" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="Original_ID" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="ID" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="Int32" Direction="Input" ParameterName="IsNull_Name" Precision="0" ProviderType="Integer" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="True" SourceVersion="Original">
                      </Parameter>
                      <Parameter AllowDbNull="True" AutogeneratedName="" DataSourceName="" DbType="String" Direction="Input" ParameterName="Original_Name" Precision="0" ProviderType="VarWChar" Scale="0" Size="0" SourceColumn="Name" SourceColumnNullMapping="False" SourceVersion="Original">
                      </Parameter>
                    </Parameters>
                  </DbCommand>
                </UpdateCommand>
              </DbSource>
            </MainSource>
            <Mappings>
              <Mapping SourceColumn="ID" DataSetColumn="ID" />
              <Mapping SourceColumn="Name" DataSetColumn="Name" />
            </Mappings>
            <Sources>
            </Sources>
          </TableAdapter>
        </Tables>
        <Sources>
        </Sources>
      </DataSource>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="manytomanyDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true" msprop:Generator_UserDSName="manytomanyDataSet" msprop:Generator_DataSetName="manytomanyDataSet">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Fruechte" msprop:Generator_UserTableName="Fruechte" msprop:Generator_RowDeletedName="FruechteRowDeleted" msprop:Generator_RowChangedName="FruechteRowChanged" msprop:Generator_RowClassName="FruechteRow" msprop:Generator_RowChangingName="FruechteRowChanging" msprop:Generator_RowEvArgName="FruechteRowChangeEvent" msprop:Generator_RowEvHandlerName="FruechteRowChangeEventHandler" msprop:Generator_TableClassName="FruechteDataTable" msprop:Generator_TableVarName="tableFruechte" msprop:Generator_RowDeletingName="FruechteRowDeleting" msprop:Generator_TablePropName="Fruechte">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ID" msprop:Generator_UserColumnName="ID" msprop:Generator_ColumnVarNameInTable="columnID" msprop:Generator_ColumnPropNameInRow="ID" msprop:Generator_ColumnPropNameInTable="IDColumn" type="xs:int" />
              <xs:element name="Name" msprop:Generator_UserColumnName="Name" msprop:Generator_ColumnVarNameInTable="columnName" msprop:Generator_ColumnPropNameInRow="Name" msprop:Generator_ColumnPropNameInTable="NameColumn" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="50" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="p_f" msprop:Generator_UserTableName="p_f" msprop:Generator_RowDeletedName="p_fRowDeleted" msprop:Generator_RowChangedName="p_fRowChanged" msprop:Generator_RowClassName="p_fRow" msprop:Generator_RowChangingName="p_fRowChanging" msprop:Generator_RowEvArgName="p_fRowChangeEvent" msprop:Generator_RowEvHandlerName="p_fRowChangeEventHandler" msprop:Generator_TableClassName="p_fDataTable" msprop:Generator_TableVarName="tablep_f" msprop:Generator_RowDeletingName="p_fRowDeleting" msprop:Generator_TablePropName="p_f">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="pID" msprop:Generator_UserColumnName="pID" msprop:Generator_ColumnVarNameInTable="columnpID" msprop:Generator_ColumnPropNameInRow="pID" msprop:Generator_ColumnPropNameInTable="pIDColumn" type="xs:int" default="-1" />
              <xs:element name="fID" msprop:Generator_UserColumnName="fID" msprop:Generator_ColumnVarNameInTable="columnfID" msprop:Generator_ColumnPropNameInRow="fID" msprop:Generator_ColumnPropNameInTable="fIDColumn" type="xs:int" default="-1" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Personen" msprop:Generator_UserTableName="Personen" msprop:Generator_RowDeletedName="PersonenRowDeleted" msprop:Generator_RowChangedName="PersonenRowChanged" msprop:Generator_RowClassName="PersonenRow" msprop:Generator_RowChangingName="PersonenRowChanging" msprop:Generator_RowEvArgName="PersonenRowChangeEvent" msprop:Generator_RowEvHandlerName="PersonenRowChangeEventHandler" msprop:Generator_TableClassName="PersonenDataTable" msprop:Generator_TableVarName="tablePersonen" msprop:Generator_RowDeletingName="PersonenRowDeleting" msprop:Generator_TablePropName="Personen">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="ID" msprop:Generator_UserColumnName="ID" msprop:Generator_ColumnVarNameInTable="columnID" msprop:Generator_ColumnPropNameInRow="ID" msprop:Generator_ColumnPropNameInTable="IDColumn" type="xs:int" />
              <xs:element name="Name" msprop:Generator_UserColumnName="Name" msprop:Generator_ColumnVarNameInTable="columnName" msprop:Generator_ColumnPropNameInRow="Name" msprop:Generator_ColumnPropNameInTable="NameColumn" minOccurs="0">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:maxLength value="50" />
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
    <xs:unique name="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:Fruechte" />
      <xs:field xpath="mstns:ID" />
    </xs:unique>
    <xs:unique name="Personen_Constraint1" msdata:ConstraintName="Constraint1" msdata:PrimaryKey="true">
      <xs:selector xpath=".//mstns:Personen" />
      <xs:field xpath="mstns:ID" />
    </xs:unique>
  </xs:element>
  <xs:annotation>
    <xs:appinfo>
      <msdata:Relationship name="Fruechtep_f" msdata:parent="Fruechte" msdata:child="p_f" msdata:parentkey="ID" msdata:childkey="fID" msprop:Generator_UserRelationName="Fruechtep_f" msprop:Generator_RelationVarName="relationFruechtep_f" msprop:Generator_UserChildTable="p_f" msprop:Generator_UserParentTable="Fruechte" msprop:Generator_ParentPropName="FruechteRow" msprop:Generator_ChildPropName="Getp_fRows" />
      <msdata:Relationship name="Personenp_f" msdata:parent="Personen" msdata:child="p_f" msdata:parentkey="ID" msdata:childkey="pID" msprop:Generator_UserRelationName="Personenp_f" msprop:Generator_RelationVarName="relationPersonenp_f" msprop:Generator_UserChildTable="p_f" msprop:Generator_UserParentTable="Personen" msprop:Generator_ParentPropName="PersonenRow" msprop:Generator_ChildPropName="Getp_fRows" />
    </xs:appinfo>
  </xs:annotation>
</xs:schema>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Systems Engineer
Germany Germany
Student of Systems Engineering and Engineering Cybernetics

Comments and Discussions