C# දන්න අය දුවලා එන්න

crazycasper

Well-known member
  • Oct 22, 2008
    2,441
    226
    63
    Negombo
    C# දන්න අය දුවලා එන්න

    මචංලා.. මට c# වල ලේබල් එකක් හදා ගන්න ඔනි. නේම් එක වෙන්න ඔනි String+Integer කොහොමද කරන්නේ බන්??

    Label XXXXX = new Label();
     
    Last edited:

    crazycasper

    Well-known member
  • Oct 22, 2008
    2,441
    226
    63
    Negombo
    int offset = 0;
    string prefix = "First";
    Label lblShow = new Label();
    lblShow.Name = prefix + offset.ToString();

    ohoma keruwata prefix + offset.ToString() walin ena label name eka passe use karanna behene ban. Create karaddima oya name eken create karanna berida ban?
     

    crazycasper

    Well-known member
  • Oct 22, 2008
    2,441
    226
    63
    Negombo
    ba mchan ehema Ba

    umbata raun time ekedi label create karanna one nam ekata wena krmayak thiyanwaa uda vidhiyata karanna bA

    Run time ekedi newei macxhan. button click ekedi. Label eka create wela eka panel ekata add wenna oni
    panel1.Controls.Add(this.labelname);
    oke labelname kiyanne passe wenas karagaththa name eka("lbl" + lblCounter.ToString();)

    Mekata wisandumak keepanko thankx machan
     

    Banned

    Well-known member
  • Dec 19, 2009
    2,625
    328
    83
    Here I am....
    PHP:
    Button[] btnArr = new Button[COUNT]; //count is the amount <strong  class="highlight">of</strong> <strong  class="highlight">buttons</strong> this <strong  class="highlight">array</strong> can hold.
    
    //Add/Change <strong class="highlight">a</strong> button:
    btnArr[indx] = IAmButton; //indx is the position, IAmButton is the button you are adding.
    
    //Get <strong class="highlight">a</strong> button:
    IAmButton = btnArr[indx];
    
    //Get <strong class="highlight">a</strong> specific button. Not so sure about this one...
    TempButton = btnArr.Controls.Find(name); //name is <strong  class="highlight">a</strong> string, that you named the button  you looking for.

    Try this and see. same goes with Labels as well. ( I haven't tried this)
     

    crazycasper

    Well-known member
  • Oct 22, 2008
    2,441
    226
    63
    Negombo
    private void button1_Click(object sender, EventArgs e)
    {

    String labelname = "lbl" + lblCounter.ToString();

    Label lbl = new Label();
    lbl.Name = labelname;
    lbl.Text = "= C";
    lbl.AllowDrop = true;
    lbl.Visible = true;
    panel1.Controls.Add(this.labelname);

    Helper.ControlMover.Init(this.labelname);
    ++lblCounter;


    //MessageBox.Show(lbl.Name);
    }
     

    crazycasper

    Well-known member
  • Oct 22, 2008
    2,441
    226
    63
    Negombo
    PHP:
    Button[] btnArr = new Button[COUNT]; //count is the amount <strong  class="highlight">of</strong> <strong  class="highlight">buttons</strong> this <strong  class="highlight">array</strong> can hold.
    
    //Add/Change <strong class="highlight">a</strong> button:
    btnArr[indx] = IAmButton; //indx is the position, IAmButton is the button you are adding.
    
    //Get <strong class="highlight">a</strong> button:
    IAmButton = btnArr[indx];
    
    //Get <strong class="highlight">a</strong> specific button. Not so sure about this one...
    TempButton = btnArr.Controls.Find(name); //name is <strong  class="highlight">a</strong> string, that you named the button  you looking for.

    Try this and see. same goes with Labels as well. ( I haven't tried this)
    ok macho try karala balannam thankx