I have a winforms application with a parent panel contains PictureBox and Label.
The application has an event on mouse enter on the parent panel to do some animation that hides the picturebox and shows the label.
It also has another event on mouse leave to handle the animation that hides the label and shows picture box.
What's happening is when mouse enters panel, animation kicks in and does what it does, but when the mouse enters label it practically leaves panel and the reverse animation kicks in.
My question is -
how can I prevent mouse leave event when my mouse enters child control of the panel?
Check if the mouse is still in the panel
private void Panel1_MouseLeave(object sender, EventArgs e)
{
if (!(sender as Panel).ClientRectangle.Contains(PointToClient(Control.MousePosition)))
{
//do animation
}
}
I am looking for white regions of button image to turn gray when Enabled is set to false. The text is currently drawn in front of the button with the color changing appropriately (i.e. when Enabled is set to false it turns gray). Currently, BackgroundImage is set to the button image with BackgroundImageLayout set to Stretch so it fits across entire button. Any help is appreciated. Thanks.
If your enabled value is from a check box, then you should be able to wire up the eventhandler of the checkbox to do the updating for you. see example below
private void checkbutton_OnCheckedChanged(object sender, EventArgs e)
{
if(checkbutton.checked)
//change button image to disabled
else
//switch to other button image type
}
The code can generate rectangles (Rectangle rectangle) at runtime. The position of rectangles may change according to users' choices.
I want to add code in the method where it creates rectangles to make the rectangles clickable. And after user clicking the rectangle, there will be a new window to show content just like text.
You can use Contains method of the Rectangle object.
private Rectangle _myRectangle;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (this._myRectangle.Contains(e.Location))
{
}
}
Create a label control with the border property and transaparent background(so that it will look as rectangle) and add click event handler for each label you add. It will be good if you create your own Rectangle control by deriving from Label class or you can create your own control(Many other solutions).
I would consider handling the click event on the window itself (or whatever your "background" control is), getting its coordinates, and comparing those to the known locations/sizes of your rectangles.
I have a SplitContainer control, and the Splitter in the middle is very ugly. By setting the BackColor of the SplitContainer to (insert color here), then setting the BackColor of Panel1 and Panel2 to white, I can have my splitter looking nice. But by default, Windows puts the selection mark over the Splitter, even before it's selected.
How can I make sure that the selection mark never shows on the Splitter?
I think by "Selection Marker Crap", you mean the fuzzy line that indicates the control is selected. If you don't want this showing up, set some other control to be selected at startup. Something like:
Textbox1.Selected = true;
This should solve your issue if it is just one of it not being selected. However, this will come back if you select the item to resize something. In that case, you could put something in the mouse_up event to move the selection off of the control. That way, the user moves the splitter bar and then when they let go, the selection gets cleared off of the splitter.
Another way would be to make the splitter bar narrow enough that the gray fuzzy line doesn't show up. To do this, you could do the following (tested):
splitContainer1.BorderStyle = BorderStyle.FixedSingle;
splitContainer1.SplitterWidth = 1;
I experienced the same problem, and fixed it by setting TabStop to False in the Properties window for SplitContainer1.
This could annoy people who depend or insist on using the keyboard to operate every aspect of your form, but other than that it will work. Controls inside the SplitContainer will remain tab-able, just not the SplitContainer itself.
This code will move the focus from the splitContainer to TreeView shortly after moved.
private void splitContainer1_SplitterMoved(object sender, SplitterEventArgs e) {
if(this.splitContainer1.CanFocus) {
this.splitContainer1.ActiveControl = this.treeView1;
}
}
You could add an event handler to steal the focus from the container on MouseUp's... It's a little messy but it works. :)
I tried a lot to remove splitter but nothing work. I did some different why we need to use splitter for that we can use picture box control make it width (or) height depend upon your project set 5 or 3 .... after picture box mouse move event write code like...
picturebox property-cursor change the cursor type Hsplit its look like splitter
private void picturebox1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)//this for mouse left click its work
{
//write you code here if you use panel set panel height or width it reaches...
Cursor.Position = new Point(e.X, e.Y); // this for mouse cursor position according your //project do some fine tune you will get its work...
}
its work because i tried lot for this and i itself found this method...
I set the TabStop to false and it went away.
Most simple solution i found/made - create a button, select it, and hide it.
All via code. there is not side effects or problems with this, place it in the forms load event.
Button DeSelectButton = new Button();
this.Controls.Add(DeSelectButton);
DeSelectButton.Select();
DeSelectButton.Visible = false;
I would like to disable displaying of the content of the window when resizing, is it possible? The problem is that when I'm resizing my window the controls redraw on correct positions but it doesn't look good because it's not done fluently.
EDIT: I would like a code that would manage the following scenario:
I click on the corner of window
Now only the border of window is visible - the middle part is transparent
I set the size of the window by mouse
I release the mouse button and the middle part of the window will appear
EDIT II:
I've got the MDI application and it doesn't support transparency for child windows
An idea is to put all the controls in a panel and set it's visibility to false on the resize event of the form.
Edit: this will make the form transparent while resizing.
private void Form1_ResizeBegin(object sender, EventArgs e)
{
panel1.Visible = false;
Form1.ActiveForm.TransparencyKey = Color.Transparent;
}
private void Form1_ResizeEnd(object sender, EventArgs e)
{
panel1.Visible = true;
Form1.ActiveForm.TransparencyKey = Color.Gray; // or whatever color your form was
}