private void btn_Click(object sender, EventArgs e) { //here i need the magic, on click i need the infoButton nect to me to be visible MyCustomButton button = sender as MyCustomButton; button.InfoButton.Visible = true; }
private void createContractButton() { MyCustomButton contractButton = contractButtonCreation("contractButton"); flowLayoutPanel1.Controls.Add(contractButton); contractButton.Click += new EventHandler(btn_Click); // Create new infoButton here, tied directly to the ContractButton you have just created contractButton.InfoButton = this.createInfoButton(); }
MyCustomButton contractButtonCreation(string contract) { MyCustomButton b = new MyCustomButton(); b.FlatAppearance.BorderSize = 1; b.FlatStyle = FlatStyle.Flat; b.Name = contract; b.Size = new Size(150, 80); b.Text = contract; b.UseVisualStyleBackColor = false; return(b); }