diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml new file mode 100644 index 0000000..48a24dd --- /dev/null +++ b/.github/workflows/gitleaks.yaml @@ -0,0 +1,38 @@ +name: Secret Value found! +on: + push: + public: +jobs: + scan: + name: gitleaks + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install the gitleaks + run: wget https://github.com/zricethezav/gitleaks/releases/download/v8.15.2/gitleaks_8.15.2_linux_x64.tar.gz + shell: pwsh + - name: Extract the tar file + run: tar xzvf gitleaks_8.15.2_linux_x64.tar.gz + - name: Generate the report + id: gitleaks + run: $GITHUB_WORKSPACE/gitleaks detect -s $GITHUB_WORKSPACE -f json -r $GITHUB_WORKSPACE/leaksreport.json + shell: bash + continue-on-error: true + - name: Setup NuGet.exe + if: steps.gitleaks.outcome != 'success' + uses: nuget/setup-nuget@v1 + with: + nuget-version: latest + - name: Install the dotnet + if: steps.gitleaks.outcome != 'success' + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '3.1.x' + - name: Install the report tool packages + if: steps.gitleaks.outcome != 'success' + run: | + nuget install "Syncfusion.Email" -source "https://nexus.syncfusion.com/repository/nuget-hosted/" + dir $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1 + dotnet $GITHUB_WORKSPACE/Syncfusion.Email.1.0.0/lib/netcoreapp3.1/Email.dll "citeam@syncfusion.com" "$GITHUB_REF_NAME" ${{ secrets.NETWORKCREDENTIALS }} ${{ secrets.NETWORKKEY }} "$GITHUB_WORKSPACE" + exit 1 diff --git a/README.md b/README.md index 1b8ddf7..65dd7e5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,52 @@ -# how-to-disable-some-items-winforms-combobox-dropdown -This sample shows how to disable some items winforms combobox dropdown. +# how-to-disable-items-winforms-combobox-dropdown +This example demonstrates how to disable items from a winforms combobox dropdown. For more details please refer [how to disable items from winforms combobox dropdown](https://www.syncfusion.com/kb/11254/how-to-disable-some-items-winforms-combobox-dropdown). + +## Changing forecolor for disabled items in dropdown +You can change the forecolor for disabled items by handling SfComboBox.DropDownListView.DrawItem event to show the items is disabled. + +# C# + + sfComboBox.DropDownListView.DrawItem += DropDownListView_DrawItem; + + private void DropDownListView_DrawItem(object sender, Syncfusion.WinForms.ListView.Events.DrawItemEventArgs e) + { + bool isItemEnable = (this.sfComboBox.ComboBoxMode == ComboBoxMode.MultiSelection && this.sfComboBox.AllowSelectAll && e.ItemIndex == 0) ? true : (e.ItemData as Details).IsEnabled; + if (!isItemEnable) + { + e.Style.BackColor = Color.LightGray; + e.Style.ForeColor = Color.Gray; + } + } + +## Handling selection for disabled items in dropdown +Selection of disabled items in multi selection mode handled using SfComboBox.DropDownListView.SelectionChanged and SfComboBox.DropDownListView.ItemChecking event. In single selection mode, selection is handled using SfComboBox.DropDownListView.SelectionChanging event. + +# C# + + private void DropDownListView_SelectionChanged(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangedEventArgs e) + { + if (e.AddedItems.Count == this.sfComboBox.DropDownListView.View.Items.Count)S + { + for (int i = 0; i < this.sfComboBox.DropDownListView.CheckedItems.Count; i++) + { + if ((this.sfComboBox.DropDownListView.CheckedItems[i] as Details).IsEnabled == false) + this.sfComboBox.DropDownListView.CheckedItems.RemoveAt(i); + } + } + } + + private void DropDownListView_ItemChecking(object sender, Syncfusion.WinForms.ListView.Events.ItemCheckingEventArgs e) + { + bool isItemEnable = (this.sfComboBox.ComboBoxMode == ComboBoxMode.MultiSelection && this.sfComboBox.AllowSelectAll && e.ItemIndex == 0) ? true : (e.ItemData as Details).IsEnabled; + if (!isItemEnable) + e.Cancel = true; + } + + private void DropDownListView_SelectionChanging(object sender, Syncfusion.WinForms.ListView.Events.ItemSelectionChangingEventArgs e) + { + if (e.AddedItems.Count > 0 && !(e.AddedItems[0] as Details).IsEnabled && e.AddedItems.Count != this.sfComboBox.DropDownListView.View.Items.Count) + e.Cancel = true; + } + +![Disable items in ComboBox](SfComboBox/SfComboBox/ComboBox%20Images/Disable%20some%20items%20in%20ComboBox.png) + diff --git a/SfComboBox/SfComboBox/ComboBox Images/Disable some items in ComboBox.png b/SfComboBox/SfComboBox/ComboBox Images/Disable some items in ComboBox.png new file mode 100644 index 0000000..9357797 Binary files /dev/null and b/SfComboBox/SfComboBox/ComboBox Images/Disable some items in ComboBox.png differ