Click here to Skip to main content
15,891,951 members
Home / Discussions / C#
   

C#

 
AnswerRe: Missing TCP Packets Pin
Dave Kreskowiak16-Aug-14 4:29
mveDave Kreskowiak16-Aug-14 4:29 
GeneralRe: Missing TCP Packets Pin
M Riaz Bashir16-Aug-14 19:54
M Riaz Bashir16-Aug-14 19:54 
AnswerRe: Missing TCP Packets Pin
Rob Philpott16-Aug-14 6:34
Rob Philpott16-Aug-14 6:34 
GeneralRe: Missing TCP Packets Pin
M Riaz Bashir16-Aug-14 19:54
M Riaz Bashir16-Aug-14 19:54 
QuestionThread Freeze when trying Abort Pin
Member 1098515215-Aug-14 12:17
Member 1098515215-Aug-14 12:17 
GeneralRe: Thread Freeze when trying Abort Pin
PIEBALDconsult15-Aug-14 12:47
mvePIEBALDconsult15-Aug-14 12:47 
QuestionSummary Report in GridView Pin
sk_ko14-Aug-14 22:02
sk_ko14-Aug-14 22:02 
AnswerRe: Summary Report in GridView Pin
Chris Quinn14-Aug-14 22:36
Chris Quinn14-Aug-14 22:36 
AnswerRe: Summary Report in GridView Pin
Mycroft Holmes14-Aug-14 23:00
professionalMycroft Holmes14-Aug-14 23:00 
GeneralScope of Share point and Silverlight Pin
Member 1059394814-Aug-14 3:40
Member 1059394814-Aug-14 3:40 
GeneralRe: Scope of Share point and Silverlight Pin
Richard MacCutchan14-Aug-14 4:22
mveRichard MacCutchan14-Aug-14 4:22 
Questionhow do i make each combo box to show a dropdown of the value of the Quantity it has fetched. Pin
Member 1050484913-Aug-14 9:02
Member 1050484913-Aug-14 9:02 
SuggestionRe: how do i make each combo box to show a dropdown of the value of the Quantity it has fetched. Pin
ZurdoDev13-Aug-14 9:24
professionalZurdoDev13-Aug-14 9:24 
QuestionHow to increment div count in path Pin
Member 1098388513-Aug-14 6:09
Member 1098388513-Aug-14 6:09 
Questionc# Play Video Fullscreen Pin
Member 416962813-Aug-14 5:20
Member 416962813-Aug-14 5:20 
AnswerRe: c# Play Video Fullscreen Pin
Simon_Whale13-Aug-14 5:41
Simon_Whale13-Aug-14 5:41 
GeneralRe: c# Play Video Fullscreen Pin
Member 416962813-Aug-14 5:53
Member 416962813-Aug-14 5:53 
GeneralRe: c# Play Video Fullscreen Pin
Dave Kreskowiak13-Aug-14 6:05
mveDave Kreskowiak13-Aug-14 6:05 
GeneralRe: c# Play Video Fullscreen Pin
Member 416962813-Aug-14 8:42
Member 416962813-Aug-14 8:42 
GeneralRe: c# Play Video Fullscreen Pin
Dave Kreskowiak13-Aug-14 12:27
mveDave Kreskowiak13-Aug-14 12:27 
GeneralRe: c# Play Video Fullscreen Pin
Bernhard Hiller13-Aug-14 21:48
Bernhard Hiller13-Aug-14 21:48 
Question[CheckBox ComboBox] Strange problem with ComboBox.CheckBoxItems[].Checked = true Pin
Member 1062093513-Aug-14 4:17
Member 1062093513-Aug-14 4:17 
Hi,

i have a very strange problem with CheckBox ComboBox Extending the ComboBox Class and Its Items[^]

First, i have two of them on my form. When I check a Item in one of them, i call a method that reloads the entries of the second ComboBox consider which Item was selected in the first ComboBox, after that the method checks the Items which was checked before the entries of the second ComboBox were reload. This should work in two ways.

It works fine when I Select one Item in the first ComboBox and one item in the second ComboBox (My Method checks the "earlier checked Items of the other ComboBox") but when I select two or more Items in the second ComboBox the method dont checks the "earlier checked Items". I hope it was unterstandable, my english isn't the best...please ask when you have any questions.

Here is my Code.

1. ComboBox (cbArticle) CheckBoxCheckedChanged Event:
C#
private void cbArticle_CheckBoxCheckedChanged(object sender, EventArgs e)
{
    //If minimum ONE GroupCode is selected
    if (cbArticle.Text != "Artikel auswählen")
    {
        cbArticle.ForeColor = SystemColors.WindowText;

        GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));

        //Gets all selected Methods, necessary for Checking the "Old selected Methods" after the Methods ComboBox Itemlist has realoaded
        string[] arrMethods = cbMethod.Text.Split(',');
        //Clear and reload the Methods
        cbMethod.Items.Clear();
        FillMethods();

        //Checks the "Old selected Methods"
        cbMethod.CheckBoxCheckedChanged -= cbMethod_CheckBoxCheckedChanged;
        for (int i = 0; i < arrMethods.Length; i++)
        {
            try
            {
                cbMethod.CheckBoxItems[arrMethods[i].Trim()].Checked = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        cbMethod.CheckBoxCheckedChanged += cbMethod_CheckBoxCheckedChanged;
    }
    //If NO GroupCode was selected --> startup initializing
    else
    {
        cbArticle.ForeColor = SystemColors.GrayText;
        FillMethods();

        if (finished)
        {
            GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));
        }
    }
}



2. ComboBox (cbMethod) CheckBoxCheckedChanged Event:
C#
private void cbMethod_CheckBoxCheckedChanged(object sender, EventArgs e)
{
    //If minimum ONE Method was selected
    if (cbMethod.Text != "Methode(n) auswählen")
    {
        cbMethod.ForeColor = SystemColors.WindowText;

        GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));

        //Gets all selected GroupCodes, necessary for Checking the "Old selected GroupCodes" after the Article ComboBox Itemlist has realoaded
        string[] arrArticles = cbArticle.Text.Split(',');
        ////Clear and reload the GroupCodes
        cbArticle.Items.Clear();
        FillGroupCodes();

        //Checks the "Old selected GroupCodes"
        cbArticle.CheckBoxCheckedChanged -= cbArticle_CheckBoxCheckedChanged;
        for (int i = 0; i < arrArticles.Length; i++)
        {
            try
            {
                cbArticle.CheckBoxItems[arrArticles[i].Trim()].Checked = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        cbArticle.CheckBoxCheckedChanged += cbArticle_CheckBoxCheckedChanged;
    }
    else
    {
        cbMethod.ForeColor = SystemColors.GrayText;
        FillGroupCodes();

        if (finished)
        {
            GetQueryType(gbTimespan.Controls.OfType<RadioButton>().FirstOrDefault(n => n.Checked));
        }
    }
}


When I debug the Code it works fine every time. I can see that the checkbox CheckedStatus is checked. But when the Method has ended and my Application switches back to the UI the CheckBoxes aren't checked... I call no other Methods (checked in debugger) but I can see that the CheckBoxComboBox.cs opens in Visual Studio it jumps in the following Code Blocks.

C#
public partial class CheckBoxComboBox : PopupComboBox
{
    #region EVENTS & EVENT HANDLERS

    public event EventHandler CheckBoxCheckedChanged;

    private void Items_CheckBoxCheckedChanged(object sender, EventArgs e)
    {
        OnCheckBoxCheckedChanged(sender, e);
    }

    #endregion

    #region EVENT CALLERS and OVERRIDES e.g. OnResize()

    protected void OnCheckBoxCheckedChanged(object sender, EventArgs e)
    {
        string ListText = GetCSVText(true);
        // The DropDownList style seems to require that the text
        // part of the "textbox" should match a single item.
        if (DropDownStyle != ComboBoxStyle.DropDownList)
            Text = ListText;
        // This refreshes the Text of the first item (which is not visible)
        else if (DataSource == null)
        {
            Items[0] = ListText;
            // Keep the hidden item and first checkbox item in
            // sync in order to ensure the Synchronise process
            // can match the items.
            CheckBoxItems[0].ComboBoxItem = ListText;
        }

        EventHandler handler = CheckBoxCheckedChanged;
        if (handler != null)
            handler(sender, e);
    }
...
}


C#
/// <summary>
/// The CheckBox items displayed in the Popup of the ComboBox.
/// </summary>
[ToolboxItem(false)]
public class CheckBoxComboBoxItem : CheckBox
{
    #region PROTECTED MEMBERS

    protected override void OnCheckedChanged(EventArgs e)
    {
        // Found that when this event is raised, the bool value of the binded item is not yet updated.
        if (_CheckBoxComboBox.DataSource != null)
        {
            PropertyInfo PI = ComboBoxItem.GetType().GetProperty(_CheckBoxComboBox.ValueMember);
            PI.SetValue(ComboBoxItem, Checked, null);
        }
        base.OnCheckedChanged(e);
        // Forces a refresh of the Text displayed in the main TextBox of the ComboBox,
        // since that Text will most probably represent a concatenation of selected values.
        // Also see DisplayMemberSingleItem on the CheckBoxComboBox for more information.
        if (_CheckBoxComboBox.DataSource != null)
        {
            string OldDisplayMember = _CheckBoxComboBox.DisplayMember;
            _CheckBoxComboBox.DisplayMember = null;
            _CheckBoxComboBox.DisplayMember = OldDisplayMember;
        }
    }

    #endregion


Please help me...I am totally frustrated after sitting 2-3 days on this issue...
SuggestionRe: [CheckBox ComboBox] Strange problem with ComboBox.CheckBoxItems[].Checked = true Pin
Richard Deeming13-Aug-14 4:57
mveRichard Deeming13-Aug-14 4:57 
GeneralRe: [CheckBox ComboBox] Strange problem with ComboBox.CheckBoxItems[].Checked = true Pin
Member 1062093513-Aug-14 20:02
Member 1062093513-Aug-14 20:02 
QuestionRegarding the usage of generic in real life Pin
Tridip Bhattacharjee12-Aug-14 21:20
professionalTridip Bhattacharjee12-Aug-14 21:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.