Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Ho to convert BLOB data to readable format Pin
Afzaal Ahmad Zeeshan17-Aug-15 2:23
professionalAfzaal Ahmad Zeeshan17-Aug-15 2:23 
QuestionSent from one computer to another keystroke Pin
goldsoft15-Aug-15 19:15
goldsoft15-Aug-15 19:15 
AnswerRe: Sent from one computer to another keystroke Pin
Dave Kreskowiak16-Aug-15 4:30
mveDave Kreskowiak16-Aug-15 4:30 
Questionc++ Qt or C# or JAVA !! Pin
Dreamer_X15-Aug-15 3:51
Dreamer_X15-Aug-15 3:51 
AnswerRe: c++ Qt or C# or JAVA !! Pin
OriginalGriff15-Aug-15 3:54
mveOriginalGriff15-Aug-15 3:54 
GeneralRe: c++ Qt or C# or JAVA !! Pin
Nish Nishant15-Aug-15 5:18
sitebuilderNish Nishant15-Aug-15 5:18 
GeneralRe: c++ Qt or C# or JAVA !! Pin
Pete O'Hanlon15-Aug-15 9:16
mvePete O'Hanlon15-Aug-15 9:16 
Questioncreating events for dynamically created button Pin
Member 1126181115-Aug-15 0:48
Member 1126181115-Aug-15 0:48 
hello all,

I am creating a list of textbox's dynamically using list and also have added a ok button and created a click_event for the button. But how will i fetch the textbox content that was created dynamically thru the click event of the button. Please see the code below :

public static List<string> InpBox(string title, List<string>prompt, ref string value, int TxtCnt)
{
Form form = new Form();
Button buttonOk = new Button();
Button buttonCancel = new Button();
List<string> inputTexts = new List<string>();
List<textbox> inputTextBoxes = new List<textbox>();
    form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
    form.AutoSize = true;
    form.Padding = new Padding(0, 0, 20, 20);
    form.FormBorderStyle = FormBorderStyle.FixedDialog;
    form.StartPosition = FormStartPosition.CenterScreen;
    form.MinimizeBox = false;
    form.MaximizeBox = false;
    form.AcceptButton = buttonOk;
    form.CancelButton = buttonCancel;
    form.Text = title;

    //Generate labels and text boxes
    for (int i = 1; i <= TxtCnt; i++)
    {
        //Create a new label and text box
        Label labelInput = new Label();
        TextBox textBoxNewInput = new TextBox();

        //Initialize label's property
       // labelInput.Text = "Input " + i;
        labelInput.Text = prompt[i-1];
        labelInput.Location = new Point(0,  (i * 30));
        labelInput.AutoSize = true;

        System.Drawing.SizeF sizeF = new System.Drawing.SizeF();
        System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1));
        sizeF = graphics.MeasureString(labelInput.Text, new System.Drawing.Font("Arial,Verdana,Helvetica,sans-serif", 10, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point));
        int maxTextWidthinPixel = Convert.ToInt32(sizeF.Width);

        //Initialize textBoxes Property
        textBoxNewInput.Location = new Point(maxTextWidthinPixel - 20, labelInput.Top - 3);
        textBoxNewInput.Width = 372;
        //Add the newly created text box to the list of input text boxes
        inputTextBoxes.Add(textBoxNewInput);

        //Add the labels and text box to the form
        form.Controls.Add(labelInput);
        form.Controls.Add(textBoxNewInput);
    }
    buttonOk.Text = "OK";
    buttonCancel.Text = "Cancel";
    buttonOk.Location = new Point(form.Width / 2 - buttonOk.Width / 2, inputTextBoxes[inputTextBoxes.Count - 1].Bottom + 20);
    buttonCancel.Location = new Point((form.Width / 2 + buttonOk.Width / 2)+10, inputTextBoxes[inputTextBoxes.Count - 1].Bottom + 20);
    form.Controls.Add(buttonOk);
    form.Controls.Add(buttonCancel);
    buttonOk.DialogResult = DialogResult.OK;
    buttonCancel.DialogResult = DialogResult.Cancel;
    buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
    buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
    buttonOk.Click += new EventHandler(buttonOk_Click);

    form.ClientSize = new Size(396, 135);

    //for (int i = 1; i <= inputTextBoxes.Count; i++)
    //    inputTexts[i] = inputTextBoxes[i].Text;

    DialogResult dialogResult = form.ShowDialog();
    //value = textBox.Text;
    return inputTexts;

}

assistance needed. Thanks in advance

Antony,
ansonel@gmail.com
AnswerRe: creating events for dynamically created button Pin
OriginalGriff15-Aug-15 1:19
mveOriginalGriff15-Aug-15 1:19 
AnswerRe: creating events for dynamically created button Pin
BillWoodruff15-Aug-15 2:58
professionalBillWoodruff15-Aug-15 2:58 
QuestionTimeSpan Error?? Pin
Kevin Marois14-Aug-15 12:16
professionalKevin Marois14-Aug-15 12:16 
AnswerRe: TimeSpan Error?? Pin
Matt T Heffron14-Aug-15 14:16
professionalMatt T Heffron14-Aug-15 14:16 
GeneralRe: TimeSpan Error?? Pin
Kevin Marois17-Aug-15 3:59
professionalKevin Marois17-Aug-15 3:59 
GeneralRe: TimeSpan Error?? Pin
Pete O'Hanlon17-Aug-15 4:24
mvePete O'Hanlon17-Aug-15 4:24 
GeneralRe: TimeSpan Error?? Pin
Kevin Marois17-Aug-15 4:28
professionalKevin Marois17-Aug-15 4:28 
GeneralRe: TimeSpan Error?? Pin
Ravi Bhavnani17-Aug-15 5:12
professionalRavi Bhavnani17-Aug-15 5:12 
GeneralRe: TimeSpan Error?? Pin
Pete O'Hanlon17-Aug-15 5:15
mvePete O'Hanlon17-Aug-15 5:15 
GeneralRe: TimeSpan Error?? Pin
Kevin Marois17-Aug-15 5:24
professionalKevin Marois17-Aug-15 5:24 
GeneralRe: TimeSpan Error?? Pin
Dr. John L. Aven31-Aug-15 17:16
Dr. John L. Aven31-Aug-15 17:16 
GeneralRe: TimeSpan Error?? Pin
Ravi Bhavnani17-Aug-15 5:24
professionalRavi Bhavnani17-Aug-15 5:24 
GeneralRe: TimeSpan Error?? Pin
Kevin Marois17-Aug-15 5:25
professionalKevin Marois17-Aug-15 5:25 
GeneralRe: TimeSpan Error?? Pin
Ravi Bhavnani17-Aug-15 5:35
professionalRavi Bhavnani17-Aug-15 5:35 
GeneralRe: TimeSpan Error?? Pin
Matt T Heffron17-Aug-15 6:55
professionalMatt T Heffron17-Aug-15 6:55 
GeneralRe: TimeSpan Error?? Pin
Richard Deeming17-Aug-15 7:10
mveRichard Deeming17-Aug-15 7:10 
QuestionWhy don't I see a VSTO template Pin
Gary Huck14-Aug-15 9:47
Gary Huck14-Aug-15 9:47 

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.