Click here to Skip to main content
15,888,297 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
This code working fine

I need to create rounded button...this solution is for classic button

Some solution?

What I have tried:

private void mp_kasa_pos_Load(object sender, EventArgs e)
       {
           SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;Initial Catalog=bss;Integrated Security=True");
           SqlCommand cmd = new SqlCommand("SELECT ime+'-'+cijena_sa_porezom, data FROM roba_usluge", con);


           var da = new SqlDataAdapter(cmd);
           var ItemTable = new DataTable();
           da.Fill(ItemTable);

           con.Open();
           Int32 count = ItemTable.Rows.Count;
           con.Close();

           int top = 10;
           int left = 10;
           for (int i = 1; i <= count; i++)

           {
               Button button = new Button();
               button.Size = new Size(128, 128);
               button.BackColor = Color.Transparent;
               //button.FlatStyle = FlatStyle.Flat;
               button.FlatAppearance.BorderSize = 0;
               button.Font = new System.Drawing.Font("Trebuchet MS", 10);
               button.TextAlign = ContentAlignment.TopCenter;
               button.BackgroundImageLayout = ImageLayout.Zoom;

               button.Left = left;
               button.Top = top;
               button.Text = ItemTable.Rows[i - 1][0].ToString();

               if (ItemTable.Rows[i - 1][1] != null)
               {
                   try
                   {
                       byte[] _byte = (byte[])ItemTable.Rows[i - 1][1];
                       MemoryStream ms = new MemoryStream(_byte);
                       button.BackgroundImage = System.Drawing.Image.FromStream(ms);//bilo image
                   }
                   catch { }
               }


               button.Click += new EventHandler(this.btn_Click);


               this.Controls.Add(button);
               if (i % 5 == 0)
               {
                   left = 10;
                   top += button.Height + 2;
               }
               else
               {
                   left += button.Width + 2;
               }



           }

       }
Posted
Updated 26-Apr-18 23:09pm
Comments
BillWoodruff 26-Apr-18 0:25am    
If the code is working, what's the problem ?
Goran Bibic 26-Apr-18 1:39am    
Read question...
I need to create solution for rounded button...this solution is for classic button

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900