Click here to Skip to main content
15,909,193 members
Home / Discussions / C#
   

C#

 
GeneralRe: Sockets Pin
Eddy Vluggen19-Nov-18 3:40
professionalEddy Vluggen19-Nov-18 3:40 
Questionhow to use qr code library in my project ,i m using asp.net using C# Pin
Member 1405785317-Nov-18 4:20
Member 1405785317-Nov-18 4:20 
AnswerRe: how to use qr code library in my project ,i m using asp.net using C# Pin
Richard Andrew x6417-Nov-18 4:34
professionalRichard Andrew x6417-Nov-18 4:34 
AnswerRe: how to use qr code library in my project ,i m using asp.net using C# Pin
Dave Kreskowiak17-Nov-18 5:03
mveDave Kreskowiak17-Nov-18 5:03 
AnswerRe: how to use qr code library in my project ,i m using asp.net using C# Pin
Vikram Motwani17-Nov-18 20:27
professionalVikram Motwani17-Nov-18 20:27 
QuestionEvent handlers Pin
Member 1405777317-Nov-18 2:03
Member 1405777317-Nov-18 2:03 
AnswerRe: Event handlers Pin
OriginalGriff17-Nov-18 2:27
mveOriginalGriff17-Nov-18 2:27 
AnswerRe: Event handlers Pin
BillWoodruff18-Nov-18 17:34
professionalBillWoodruff18-Nov-18 17:34 
OriginalGriff has shown you how to make all run-time created Controls use the same EventHandler. Let me add:

1. when you create a set of Controls at run-time: you probably should keep track of them ... keep a reference to the instances for future use: I got tired of writing Control specific code for this, and created a generic method:
public Dictionary<string, T> CreateControls<T>(Control container, int ncontrols, Func<T, int, string> nameGenerator, Func<T, int, Point> locGenerator)
        where T : Control
{
    Dictionary<string, T> dict = new Dictionary<string, T>();
    string name;

    for (int i = 0; i < ncontrols; i++)
    {
        T newT = Activator.CreateInstance<T>();

        container.Controls.Add(newT);

        name = nameGenerator(newT, i);
        newT.Name = name;

        dict.Add(name, newT);

        if (locGenerator != null)
        {
            newT.Location = locGenerator(newT, i);
        }
    }

    return dict;
}
Sample usage:
int hstart, vstart, hoff, voff;

hstart = 100;
vstart = 100;
hoff = 0;
voff = 60;

var tbxDict = CreateControls<TextBox>(this, 5, (tbx, i) => $"newTbx_{i}", (tbx, i) => new Point(hstart + (i * hoff), vstart + (i * voff)));

var check = tbxDict["newTbx_0"].Name;
When this is executed, five new TextBoxes are added to the Form this code runs in, a Dictionary is created and returned for easy future access to the created TextBoxes, and the new TextBoxes are placed on the Form in a column starting at 100,100. offset from each other vertically by 60 points.

The two functions (Delegates) that create the name and position of each new TextBox are passed as parameters to the 'CreateControls method.

Now, validation: that's the next chapter Smile | :)
«Where is the Life we have lost in living? Where is the wisdom we have lost in knowledge? Where is the knowledge we have lost in information?» T. S. Elliot

QuestionC# Equivalent of VB6 Function? Pin
Richard Andrew x6416-Nov-18 3:12
professionalRichard Andrew x6416-Nov-18 3:12 
AnswerRe: C# Equivalent of VB6 Function? Pin
Richard MacCutchan16-Nov-18 3:15
mveRichard MacCutchan16-Nov-18 3:15 
AnswerRe: C# Equivalent of VB6 Function? Pin
Eddy Vluggen16-Nov-18 4:05
professionalEddy Vluggen16-Nov-18 4:05 
GeneralRe: C# Equivalent of VB6 Function? Pin
Richard Andrew x6416-Nov-18 9:04
professionalRichard Andrew x6416-Nov-18 9:04 
GeneralRe: C# Equivalent of VB6 Function? Pin
Eddy Vluggen16-Nov-18 10:11
professionalEddy Vluggen16-Nov-18 10:11 
QuestionConverting nested object to JSON Not nested objects Pin
Member 1338930215-Nov-18 23:09
Member 1338930215-Nov-18 23:09 
AnswerRe: Converting nested object to JSON Not nested objects Pin
Richard Deeming16-Nov-18 1:02
mveRichard Deeming16-Nov-18 1:02 
AnswerRe: Converting nested object to JSON Not nested objects Pin
Nathan Minier16-Nov-18 1:23
professionalNathan Minier16-Nov-18 1:23 
Questionupdate option not functioning in gridview Pin
Stephanie Joanne15-Nov-18 16:38
Stephanie Joanne15-Nov-18 16:38 
QuestionRe: update option not functioning in gridview Pin
Richard MacCutchan15-Nov-18 21:44
mveRichard MacCutchan15-Nov-18 21:44 
SuggestionRe: update option not functioning in gridview Pin
Richard Deeming16-Nov-18 0:59
mveRichard Deeming16-Nov-18 0:59 
QuestionIntegrating multi-threading into this application. Are there any issues you can see arising from this? Pin
Goalie3515-Nov-18 10:50
Goalie3515-Nov-18 10:50 
AnswerRe: Integrating multi-threading into this application. Are there any issues you can see arising from this? Pin
Luc Pattyn15-Nov-18 11:12
sitebuilderLuc Pattyn15-Nov-18 11:12 
QuestionDetect Network / VPN Connection Part 2 Pin
Kevin Marois15-Nov-18 6:46
professionalKevin Marois15-Nov-18 6:46 
AnswerRe: Detect Network / VPN Connection Part 2 Pin
Richard MacCutchan15-Nov-18 10:14
mveRichard MacCutchan15-Nov-18 10:14 
GeneralRe: Detect Network / VPN Connection Part 2 Pin
Kevin Marois15-Nov-18 10:21
professionalKevin Marois15-Nov-18 10:21 
GeneralRe: Detect Network / VPN Connection Part 2 Pin
Richard MacCutchan15-Nov-18 10:27
mveRichard MacCutchan15-Nov-18 10:27 

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.