Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Member 11426986

@Member 11426986
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Disable focus in button with arrow right left up down
    M Member 11426986

    At the end of the method it does this. "but.Location = new Point (x, y);".
    The problem is that by pressing the directional arrow, it changes the location of the button and does not continue with the focus on the button it focuses on another button.

    C# help

  • Disable focus in button with arrow right left up down
    M Member 11426986

    I have a problem. When i press the arrow down, up, right or left with focus in a button, i want the button have moved for direction selected,
    But this does not happen, another button is focused. I set TabStop of the button to false, but even so with the arrows still focuses other buttons.
    Below is the code for creating the button, and the method for moving it.

    private void btnCreateNewButton_Click(object sender, EventArgs e)
    {
    Button button = new Button();
    button.Text = "";
    button.FlatStyle = FlatStyle.Popup;
    button.Left = 30;
    button.Top = 30;
    button.Width = 10;
    button.Height = 40;
    button.TabIndex = 1;
    button.TabStop = false;
    button.Click += new EventHandler(button_Click);
    button.MouseDown += new MouseEventHandler(cli_MouseDown);
    button.MouseMove += new MouseEventHandler(cli_MouseMove);
    button.PreviewKeyDown += new PreviewKeyDownEventHandler(cli_PreviewKeyDown);

            panel3.Controls.Add(button);
        }
    

    private void cli_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
    {
    Button but = sender as Button;
    if (butMensagem.Focused)
    {
    int x = but.Location.X;
    int y = but.Location.Y;

                if (e.KeyCode == Keys.Right)
                {
                    x += 1;
                }
                else if (e.KeyCode == Keys.Left)
                {
                    x -= 1;
                }
                else if (e.KeyCode == Keys.Up)
                {
                    y -= 1;
                }
                else if (e.KeyCode == Keys.Down)
                {
                    y += 1;
                }
    
                but.Location = new Point(x, y);
            }
            else
            {
                
            }
        }
    
    C# help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups