I have no clue if this is possible or not as I'm new to C#. But is it possible to make a Windows Forms look like the picture? Where you have a
gradient at top
alternating color rows
change the default text color
change the default highlight color
change the way the scroll bar looks
If so, are there tutorials for these someone can point me to?
Gradient effects will take tedious paint task. You have some example here
Alternating Row Colors,
datagridview1.AlternatingRowsDefaultCellStyle.BackColor= Color.Blue;
Change Text Color
datagridview1.RowsDefaultCellStyle.ForeColor = Color.Red;
Change Highlight Color
`datagridview1.RowsDefaultCellStyle.SelectionBackColor = Color.Pink;
As far as I know scroll-bar will have the look of your current system theme and cant be change that easily unless you write your own code for it.
Regarding skinning (gradients, custom scroll bar): WinForms are a wrapper around Win32 native controls. They were not designed with visual appearance customization in mind. It is possible but will require an awful lot of work: There is nothing comparable to CSS in WinForms.
An arguably easier alternative would be WPF.
Of course, the most straightforward might be to look for a 3rd party component such as Krypton's DataGrid (free).
Related
I'm looking to add a 'mapview' type control to my project.
It must have a 'main map' image with clickable transparent rectangles with borders and icons/images that can be animated when an event occurs.
What would be the best way of achieving this using windows forms in C#?
My first thought was to use a picture box with other items on top of it but I might run into problems with transparency etc.
Are there any libraries or anything out there that would be able to achieve this?
No need for a library, really:
I would go for a regular doublebuffered Panel subclass or even a PictureBox subclass for the board/map along with a movable Label or Panel subclass fpr the rectangles/items.
Important: Make sure the Labels are not just 'put on top' of the PictureBox but really nested!! (lbl.Parent = pbox). Then transparency will work just fine..
Since PictueBox is not a 'container', to nest a control in it you need code. But since you probably want to create them dynamically this is not an issue anyway.
This assumes that the rectangles are not overlapping! For overlapping controls transparency in winforms will not work.
The clearer you understand the 'animate when event' part the easier the rest of the code will be..
Since you mention 'animation', a word of warning: Simple animation, especially in reponse to a user action is doable; for more classy animation you may run into the limits of winforms.
Is it possible to do animations, like moving buttons and stuff in WinForms and Compact Framework?
Yes you can, the minimal you can do is change the top and left and height and width of a control, make it look like an animation
Using loop constructs and changing display position parameters or alternating colours and border styles etc you can do minimal animation. You will just have to get creative with your code and see what you can do.
You can find animation about winforms
https://web.archive.org/web/20141223080308/http://bobpowell.net/animation.aspx
I'm making a very simple text editor and I'd like to color the background of the whole selected line (left to right). And I'd like it to follow the cursor so if I go down two lines the background changes.
I'm looked a lot on here and google and found nothing interesting, it always colors the text instead of the background and it does not color the entire line, etc.
Any suggestions are welcome!
Thanks!
I am not sure you can easily color the full line where the caret is in the standard RichTextBox control, I think I mostly heard only the background of already entered text could be colored.
If you are not forced to stay with the standard RichText you can have a look at this:
ScintillaNET
this editor has an incredible amount of features, the only thing is that I am not sure if it supports many different fonts otr picture embedding, tables and so on.
if ScintillaNET is nout enough either I would then try with DevExpress components for Windows Forms, extremely feature rich and powerful, in theri demo they have basically made a text editor with tables, mailmerge and so many other things it looks almost like MS Word.
You know those color picker buttons with a little rectangle in it, displaying the currently selected color? Like in MS Office products.
I would like to implement one using C# / .NET. So I've got a nice little icon with a magenta-colored rectangle (which is to display the color) and a transparent background.
I can think of two ways how this could be done, but they're both not really elegant:
Edit the icon using graphics software to have a solid background color instead of transparency and resize it to be exactly as large as the button containing it. This would allow to use TransparentColor=Manenta in combination with the button Background, however the icon would have to be edited whenever button size, toolbar BackColor or something else changes.
Edit the icon programmatically whenever a new color is selected. Would work, but seems a little bit to complex (regarding development and performance) to me.
So. Maybe I am missing the obvious, easy way to implement such a button?
Thanks in advance for any hints/suggestions/inspiration :)
You can easily override the OnPaint method and draw a rectangle with any color you desire.
Obviously, there is no elegant solution. I chose the first one, using PNG transparency and BackColor, with the drawback of having to color the png background like the background of the containing panel. Seems to be least painful this way.
I see no reason to use an icon, PNG, or any other image resource for this. That seems a complete waste of resources.
Just draw the boxes from code, drawing the colors that are currently part of the control's color list. Ideally, your control will allow the caller to add their own colors. And it wouldn't require any fiddling around with images.
I just used an owner-draw combo box when I did this, but I drew a color box as I'm describing. Very easy.
I would like to learn about creating a program that I could draw simple shapes and be able to select them for editing - like resizing, order of display, color change. Is there an online resource that someone knows of that would help me reach my goals.
thanks
"GDI+" is what you are looking for. You can start here: http://msdn.microsoft.com/en-us/library/da0f23z7.aspx
A sneaky way I used to do it was to create a custom control, remove the background from it and paint my shapes and sizes on it. Then, you can easily implement selection (override OnClick), dragging and resizing (OnMouseDown, OnMouseMove, OnMouseUp). You can then implement options like color, etc. by means of a property (see Browsable attribute and property get/setters) and a PropertyGrid control.
Anything beyond that, though - Bezier curves and such - would need something a tad more advanced, though.
The alternative is to only use such controls for the sizing handles, and do all the drawing on one central canvas - the only drawback then is figuring out how to select a shape on the canvas.