C# - Disable buttons with image - c#

I'm using C# and WinForms.
When using a button with a BackgroundImage property, when I enable/disable the button, the image doesn't get gray... Result : The user is unable to tell if the button is enabled or disabled without trying to click it.
When using a button with a Image property, the image's behavior is correct but the image is not centered in the button !
As you can see in the picture, the first button uses BackgroundImage , the second one uses Image property but the minus sign is not centered properly... How can I manage this enable/disable state with a proper image's behavior ?
Thanks in advance !

I was doing the same thing some time ago and everything worked out by just using the Image property. You could try to set ImageAlign:
button.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
Maybe increase the dimensions of the button to see if that changes anything (maybe the image is just too big for the disabled button. All I can tell you is that it should work perfectly using the Image property.

Related

Hide and show button background in unity

I am trying to make transparent (legacy) buttons in unity. I want to be able to see the button text, but not see the background button image (aka the 'clickable' area). I am not asking about hiding/showing the button and the text completely.
I have tried disabling the button, removing the Target Graphic image, setting the alpha values to 0, but none of these seems to have any effect.
Do I need to just remove the button object and write some sort of script that hangs off a text object to detect clicks?
Addendum: Geode's suggestion works nicely. Either deleting or disabling the image component will solve this problem.
I think you've been looking in the wrong area, above your Button component there is an image component which handles the graphics part of your button. Disabling or removing that will remove the white background.
Here you can see the location

C# WindowsForms: Reproduce Microsoft control

I would like to reproduce a Control in my WindowsFormsApplication that is equal to the refresh Button of the Windows Network connection form.
Does anybody know which Control it is or how to build a equal one in C#? It seems to be a PictureBox but if you hover it with the Cursor it gets a semi transparent blue colored overlay.
you can use XanderUI for this, add the button, change the button image and change both hover and click background colors to whatever color you like

How to bring an image to the Foreground on run time in Unity?

I am trying to create a game where I have to display different pictures when different buttons are clicked.
The problem when one button is pressed image appears behind all the other buttons (Except the button which is clicked to display that image). I have attached screenshots to describe my problem better. Please suggest a solution to overcome this problem.
Screenshot of the game with all Buttons :
Button when clicked Image appears but all the other buttons are infront of the image :
put a boolean to hide the buttons if the image is shown.
You need guiDepth
http://docs.unity3d.com/ScriptReference/GUI-depth.html
yourButton.guiDepth = 0;
0 = on top of everything

How do I disable user input on a WebView?

I'm having tons of issues trying to integrate Microsoft's WebView in my WinRT application and one of them is the following. I want to display the WebView and its content (which comes from a local offline server but that works like a charm) and I don't want the user to be able to click around ; basically completely disable user input on this WebView.
There is no IsEnabled property on this control so I tried:
Catching the many Pressed-like events and setting the Handled property of the event object to false in each one of the handlers
Catching the GotFocus event of the WebView to set the focus on another control immediately
Putting the WebView in a ContentControl, then set the IsEnabled property of the ContentControl to false
Obviously, none of these workarounds did work so I'm facing a brickwall here. Maybe some of you can help find a solution?
More details if that can help: the web page that is loaded contains an HTML5 canvas where the user can draw things (like in Microsoft Paint). There are also links (ahref). I dont want the user to be able to draw on this canvas, and I don't want them to be able to click on these links as well!
Thanks
Hi you can use a if the content is not animated then you can use a Rectangle instead of the WebView and in the rectangle you use a WebViewBrush, this actually take the webview and render it's content as an image on the rectangle. since it is an image no interaction is available on the rectangle, but if you have animation then you will lose them.
Generally this trick is used to show content onto the webview.

DataGridView Image Layout Stretch Bug

I'm using a DataGridView to display some data, including an image which I'm displaying in an "Image Column". To display the image properly, I set the Image Layout property to Stretch; however, I'm getting an unexpected visual effect when I click on a row or I scroll (up-down, left-right).
When I scroll, it look like the background keep a "picture" of the
movement.
When I click, the background seems to stack.
Given that I set the Image Layout property at design time, I thought the way I set it created this bug. So I tried to set the property at run time, but I had no luck.
Then I started to think it was probably another property set with "Image Layout:stretch" that can make this issue. I tried to find the property, but I found nothing to fix it.
I did not show code because I don't think it is pertinent in my situation. But if you think it is, let me know and I will post what you want.
I think you are using a transparent background image(like .png image format) that ways you are facing that type of problem.
Another issue is may be you have low graphics in your system.

Categories