Click here to Skip to main content
15,893,487 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen24-Nov-17 5:10
professionalEddy Vluggen24-Nov-17 5:10 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201828-Nov-17 17:48
C Sharp coder 201828-Nov-17 17:48 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
C Sharp coder 201828-Nov-17 17:56
C Sharp coder 201828-Nov-17 17:56 
GeneralRe: How to refresh reportviewer when SQL input data changed Pin
Eddy Vluggen29-Nov-17 0:27
professionalEddy Vluggen29-Nov-17 0:27 
Questionerror:The remote server returned an error: (411) Length Required. Pin
Urmila Pawar22-Nov-17 18:44
Urmila Pawar22-Nov-17 18:44 
AnswerRe: error:The remote server returned an error: (411) Length Required. Pin
Jochen Arndt22-Nov-17 21:28
professionalJochen Arndt22-Nov-17 21:28 
QuestionTabcontrol and treeview data binding Pin
Hervend22-Nov-17 12:59
Hervend22-Nov-17 12:59 
AnswerRe: Tabcontrol and treeview data binding Pin
Mycroft Holmes22-Nov-17 13:15
professionalMycroft Holmes22-Nov-17 13:15 
Questionhow svd(singular decompostion value) works for matrix? Pin
Isawyouoo22-Nov-17 4:00
Isawyouoo22-Nov-17 4:00 
AnswerRe: how svd(singular decompostion value) works for matrix? Pin
M-Badger22-Nov-17 4:36
M-Badger22-Nov-17 4:36 
GeneralRe: how svd(singular decompostion value) works for matrix? Pin
Isawyouoo22-Nov-17 5:00
Isawyouoo22-Nov-17 5:00 
GeneralRe: how svd(singular decompostion value) works for matrix? Pin
OriginalGriff22-Nov-17 8:26
mveOriginalGriff22-Nov-17 8:26 
GeneralRe: how svd(singular decompostion value) works for matrix? Pin
Isawyouoo23-Nov-17 11:19
Isawyouoo23-Nov-17 11:19 
Questioncan't add combobox Items (C#) Pin
Dunnewijk22-Nov-17 3:43
Dunnewijk22-Nov-17 3:43 
AnswerRe: can't add combobox Items (C#) Pin
Pete O'Hanlon22-Nov-17 4:48
mvePete O'Hanlon22-Nov-17 4:48 
GeneralRe: can't add combobox Items (C#) Pin
Dunnewijk22-Nov-17 5:04
Dunnewijk22-Nov-17 5:04 
GeneralRe: can't add combobox Items (C#) Pin
Dave Kreskowiak22-Nov-17 5:15
mveDave Kreskowiak22-Nov-17 5:15 
GeneralRe: can't add combobox Items (C#) Pin
Sascha Lefèvre22-Nov-17 5:20
professionalSascha Lefèvre22-Nov-17 5:20 
GeneralRe: can't add combobox Items (C#) Pin
Dunnewijk22-Nov-17 6:56
Dunnewijk22-Nov-17 6:56 
GeneralRe: can't add combobox Items (C#) Pin
Sascha Lefèvre22-Nov-17 7:55
professionalSascha Lefèvre22-Nov-17 7:55 
AnswerRe: can't add combobox Items (C#) Pin
Dave Kreskowiak22-Nov-17 5:02
mveDave Kreskowiak22-Nov-17 5:02 
Why on earth are you adding items to a combo box in a method that is named Getsomething and the method doesn't return anything?

Your GetcobBox method is also naive. It will only look in top-level controls on a form. If they are in containers, such as a Panel or GroupBox, they won't be found.

You've got a lot of learning to do. You're creating a ComboBox control in your GetcboBox method, then throwing it away. You're also not using a logical AND operator in your if statement, you're using a binary AND operator (&).

Your GetcboBox method should be something more like this:
C#
private ComboBox GetComboBoxByName(string name)
{
    foreach (Control control in this.Controls)
    {
        if (control is ComboBox && control.Name == name)
        {
            return control;
        }

        if (control.HasChildren)
        {
            return GetComboBoxByName(name);
        }
    }

    return null;
}

But, there's an even easier way to do it by having the .NET Framework do the work for you. Since you can't have two controls on the form with the exact same name, this will either return the control you're looking for, return null, or throw an exception because the control that was found isn't a ComboBox:
C#
private ComboBox GetComboBoxByName(string name)
{
    Control[] candidates = this.Controls.Find(name, true);
    
    return (ComboBox)candidates.FirstOrDefault();
}

Keep in mind, this is an example and is not meant to by used in a production application.
System.ItDidntWorkException: Something didn't work as expected.

C# - How to debug code[^].
Seriously, go read these articles.

Dave Kreskowiak

GeneralRe: can't add combobox Items (C#) Pin
Dunnewijk22-Nov-17 6:59
Dunnewijk22-Nov-17 6:59 
QuestionHow to filter like or = with a column in reportviewer C# Pin
C Sharp coder 201821-Nov-17 4:56
C Sharp coder 201821-Nov-17 4:56 
Rant[REPOST] How to filter like or = with a column in reportviewer C# Pin
Richard Deeming21-Nov-17 5:03
mveRichard Deeming21-Nov-17 5:03 
Questionhow i distinguish scan or keyboard value ? in windows ce ?? Pin
Member 1284514418-Nov-17 1:52
Member 1284514418-Nov-17 1:52 

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.