4
In C# is there any way to put for example buttons with a different design, or the title with a different style? I want to put my program more "Fancy".
4
In C# is there any way to put for example buttons with a different design, or the title with a different style? I want to put my program more "Fancy".
4
For buttons or titles with different designs you could simply use a Picturebox and place a specific image. Now, if you want something a little more complex, you can create a class by inheriting the Button class (in case it is a button) and change some details, overwrite events using override according to your criteria etc.
On the curiosity level, follow the code of how to create a custom button using the class Graphics:
public Form1()
{
InitializeComponent();
BotaoPersonalizado objBotao = new BotaoPersonalizado(); //Inicializando o botão personalizado.
//Incluindo a ele um evento Click:
EventHandler evento = new EventHandler(objBotao_Click);
objBotao.Click += evento;
objBotao.Location = new System.Drawing.Point(100, 200); //Definindo sua posição na tela.
objBotao.Size = new System.Drawing.Size(200, 305); //Definindo seu tamanho.
this.Controls.Add(objBotao); //Adicionando o controle ao formulário.
}
public class BotaoPersonalizado : System.Windows.Forms.UserControl
{
//Sobrescrevendo o método OnPaint para desenhar o botão:
protected override void OnPaint(PaintEventArgs e)
{
Graphics graphics = e.Graphics;
Pen pen = new Pen(Color.Blue);
float cordenadaX = 0, cordenadaY = 0, largura = 100, altura = 100; //Definindo características da elipse delimitada por um retângulo.
graphics.DrawEllipse(pen, cordenadaX, cordenadaY, largura, altura); //Desenhando a elipse.
pen.Dispose(); //Liberando os recursos usados.
}
}
void objBotao_Click(Object sender, System.EventArgs e)
{
MessageBox.Show("Olá");
}
2
You’re looking for the Windows Presentation Foundation (WPF), the Microsoft solution for rich applications. But bear in mind that there is a steep learning curve for developers Winforms. If you have any experience with rich application development (Flex, Javafx or mainly Silverlight) and a good understanding of Markup modern WPF principles are more natural. Start by researching about XAML, an XML-based language, counter-half of C# (or any other language of the .NET platform) used in component declaration.
Browser other questions tagged c# winforms
You are not signed in. Login or sign up in order to post.
suggestions for tools generates answers mainly based on opinions, I believe that this type of question does not fit here because it is almost impossible to decide which is the correct answer.
– Math
@Math I think this kind of question is valid. The answers are usually presentations from current editors most preferred by the community. This type of information is widely requested. But as you well quoted, it is almost impossible to decide which is the correct answer.
– Ricardo
@Ricardo agrees that the material may have some value, mainly while the answers are new, but again: it is almost impossible to determine which is the correct answer among a list of suggestions; moreover, over time the answers will be outdated, Who will update the answers? Nobody. This kind of question fits more in a forum than here, which is a question and answer site. See an interesting discussion at that link
– Math
I believe that a good place for this kind of information is here: http://answall.com/tags/c%23/info Anyone with enough reputation can edit the wiki tag and suggest tools, books and so on.
– Math
@Math Really, I agree with you.
– Ricardo
@Math edited Katomara’s question, specifically asking about how to put buttons or titles with different designs on C#. I think that way the scope becomes clear, and not merely a suggestion question.
– Carlos Cinelli
I agree with you @Math. But, if the author of the question changes it to be more in the line "Is it possible to customize the look/style of buttons in C#?" without requesting tools, perhaps the question becomes more interesting and valid in the scope. :)
– Luiz Vieira
@Luiz Vieira, I agree, I just edited the question.
– Carlos Cinelli
@carloscinelli I saw your issue, dude. P.S.: Personally I find it more correct in these cases to let the author edit, because he may not agree or have a different understanding of my/his. That’s why I suggested editing instead of making it. But, anyway, I think your editing should help the question. :)
– Luiz Vieira
@carloscinelli I edited some more and voted to reopen.
– bfavaretto
I voted for reopening. While the question is open-ended, the choice of technologies limits the range of possible solutions.
– OnoSendai
@bfavaretto cool
– Carlos Cinelli