C
C#12mo ago
Salight

Why doesn't it changes when i click generate ?

private void button1_Click(object sender, EventArgs e)
{
Button RuscaKelime1 = new Button();
Controls.Add(RuscaKelime1);

Point kelimePoint= new Point(20,150);
RuscaKelime1.Size = new Size(100,100);
RuscaKelime1.Location= kelimePoint;
RuscaKelime1.Text = Kilavuz.ruscaKelimeler.ElementAt(rand.Next(Kilavuz.DicLength)).Value;
}
private void button1_Click(object sender, EventArgs e)
{
Button RuscaKelime1 = new Button();
Controls.Add(RuscaKelime1);

Point kelimePoint= new Point(20,150);
RuscaKelime1.Size = new Size(100,100);
RuscaKelime1.Location= kelimePoint;
RuscaKelime1.Text = Kilavuz.ruscaKelimeler.ElementAt(rand.Next(Kilavuz.DicLength)).Value;
}
What do i have to do what i want is when i click the generate button it needs to change the button below it
No description
2 Replies
ZacharyPatten
ZacharyPatten12mo ago
we need more info to help also you should in general avoid using Top, Left to handle positioning of dynamic controls instead you should be using things like flow layout panels or the other types of panels which can handle positioning for you
Salight
SalightOP12mo ago
i didn't understand what you mean over there i am new in form apps so how can i do what you said more simply i don't know what flow layout panels
using System.Threading.Tasks;

namespace RussianPractice
{
internal class Kilavuz
{
static Random rand = new Random();
public static IDictionary<string, string> ruscaKelimeler = new Dictionary<string, string>() {

{"Привет","Merhaba" },
{"Да","Evet" },
{"Нет","Hayır" },
{"турецкий","Türk" },
{"я","Ben" }






};
public static int DicLength { get {
int x = 0;
foreach(var item in ruscaKelimeler)
{
x++;
}
return x;

} set { } }



}
}
using System.Threading.Tasks;

namespace RussianPractice
{
internal class Kilavuz
{
static Random rand = new Random();
public static IDictionary<string, string> ruscaKelimeler = new Dictionary<string, string>() {

{"Привет","Merhaba" },
{"Да","Evet" },
{"Нет","Hayır" },
{"турецкий","Türk" },
{"я","Ben" }






};
public static int DicLength { get {
int x = 0;
foreach(var item in ruscaKelimeler)
{
x++;
}
return x;

} set { } }



}
}
this is the class that i used here my main goal is the make some language game when i click generate i want to change the button that i generate to random different word
Want results from more Discord servers?
Add your server