标签: button

在一个面板中的Winforms中移动元素,没有线程

我有一个任务是使用C#在Winforms中的一个面板周围移动一个元素(Button,Label ...).

我解决了这个问题,它有效:

 private void button1_Click(object sender, EventArgs e)
    {

        // System.Threading.Thread.Sleep(100 - auto.Geschwindigkeit);
        for (int i = 0; i < panel1.Width; i++)
        {
            label1.Location = new Point(i, label1.Location.Y);
            label2.Location = new Point(i, label2.Location.Y);
            System.Threading.Thread.Sleep(50);//speed
            Application.DoEvents();
        }


    }
Run Code Online (Sandbox Code Playgroud)

但是有没有另外一种方法可以做到这一点,例如当我想要编程游戏并且我有10个标签(代表一辆驾驶汽车)时,我认为这将超载到使用Threads,因为CPU越来越高?!"System.Threading.Thread.Sleep(50);" 将是一个元素的速度,我想我需要一些更高效的东西?!

谢谢

c# label panel button winforms

0
推荐指数
1
解决办法
366
查看次数

多个交换机的监听器

我在我的应用程序中有一个包含许多开关的设置活动.我试图避免编写50个setOnCheckedChangeListener我试图在布局文件中设置onClick事件:

        <Switch
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/switchVibra"
            android:layout_weight="0.1"
            android:onClick="switchChange" />
Run Code Online (Sandbox Code Playgroud)

方法:

public void switchChange(View v){
    switch (v.getId()){
        case R.id.switchVibra:
           // Do something
           break;
   }
}
Run Code Online (Sandbox Code Playgroud)

但是,当您擦除开关时,此方法不会注册更改.还有其他选项可以避免为每个开关编写一个监听器吗?

android button listener

0
推荐指数
1
解决办法
3237
查看次数

IsEnabled绑定更新后按钮未启用

我有一堂课叫做Document

public class Document : INotifyPropertyChanged
{                  
    public event PropertyChangedEventHandler PropertyChanged;
    private void NotifyPropertyChanged(string propertyName)
    {
        if (PropertyChanged != null)
            PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }             

    private string oldId;
    public string OldId
    {
        get { return oldId; }
        set { id = value; }
    }

    private string id;
    public string Id
    {
        get { return id; }
        set { 
            id = value;
            NotifyPropertyChanged("HasChanged");
        }
    }

    private string path;
    public string Path
    {
        get { return path; }
        set { path = …
Run Code Online (Sandbox Code Playgroud)

c# wpf binding button

0
推荐指数
1
解决办法
466
查看次数

如何在动作栏上使用按钮使用碎片?

我想在片段的操作栏上添加按钮.但是我在下面给出的代码上收到错误.

这是我的片段代码,我想在此选项卡的操作栏上添加按钮

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
         final View view = inflater.inflate(R.layout.credit_main, container, false);
return view;
    }
@Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu items for use in the action bar
        MenuInflater inflater = getMenuInflater();

        inflater.inflate(R.menu.search_menu, menu);
        return super.onCreateOptionsMenu(menu);
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            // action with ID action_refresh was selected
            case R.id.search:
                Toast.makeText(getActivity(), "Refresh selected", Toast.LENGTH_SHORT)
                        .show();
                break;
            default:
                break;
        }
        return super.onOptionsItemSelected(item);
    }

}
Run Code Online (Sandbox Code Playgroud)

这里的错误是 …

android button android-fragments android-actionbar

0
推荐指数
2
解决办法
1636
查看次数

如何使用VBA将按钮的图片更改为嵌入式默认图像之一?

我试图获得一个按钮,当我单击该按钮时将其从“左箭头”更改为“右箭头”,但是我不确定如何通过VBA分配图像。我试过了Me!btnCollapseUnscheduled.Picture = "Arrow Left",但是这样会收到错误消息。

ms-access image button access-vba ms-access-2013

0
推荐指数
1
解决办法
7093
查看次数

如果没有键入11个字符,请不要启用按钮

这是我在jquery中的代码,我认为逻辑是可以的,但我仍然无法让它工作.

    $(document).ready(function(){
    $('#send').attr('disabled',true);
    $('#inputText').keyup(function(){
        if($(this).val().length == 11)
            $('#send').attr('disabled', false);            
        else
            $('#send').attr('disabled', true);
        })
     });
Run Code Online (Sandbox Code Playgroud)

这是html,输入框和按钮

<input type="text" id="inputText" placeholder="XXX-XXX-XXX" maxlength="11"/>
<input type="button" id="send" value="submit"></input>
Run Code Online (Sandbox Code Playgroud)

html jquery input button

0
推荐指数
1
解决办法
43
查看次数

添加按钮到以编程方式创建的UIView

我以编程方式创建了UIView和Button

var width = self.view.frame.width - 8
        var height = width/8

        newView.frame = CGRectMake(4, 39, width, height)
        newView.backgroundColor = UIColor.greenColor()
        self.view.addSubview(newView)

        var button = UIButton.buttonWithType(UIButtonType.System) as! UIButton
        button.frame = newView.frame
        button.backgroundColor = UIColor.whiteColor()
        button.addTarget(self, action: "buttonAction:", forControlEvents: UIControlEvents.TouchUpInside)
        button.setTitle("  All Hospitals/Clinics", forState: UIControlState.Normal)
        button.setTitleColor(UIColor.blackColor(), forState: .Normal)
        button.contentHorizontalAlignment = UIControlContentHorizontalAlignment.Left
        newView.addSubview(button)
Run Code Online (Sandbox Code Playgroud)

我希望按钮位于UIView内部,并且具有与UIView完全相同的位置,宽度和高度

但结果就是这样

在此输入图像描述

我的代码出了什么问题?

提前致谢

button uiview ios swift

0
推荐指数
2
解决办法
3761
查看次数

为什么我的按钮在Android Studio中不起作用?

我正在进行A Level计算,我正在尝试为我的Comp 4项目制作应用程序.我用按钮完成的所有其他类似乎工作正常,但主菜单上的按钮不起作用.

public class MainActivity extends AppCompatActivity {

Button bLogin;
Button bProducts;
EditText etName, etAge, etUsername;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
protected void onStart() {
    super.onStart();
}

@Override
public boolean onCreateOptionsMenu (Menu menu) {
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id= item.getItemId();
    switch (id) {
    case R.id.bLogin:
        break;
    case R.id.bProducts:
        break;
    }
    return super.onOptionsItemSelected(item);
}

public void ProductsOnClick(View b) {
    startActivity(new Intent(".Products"));
    switch (b.getId()) {
    case R.id.bProducts:
    } …
Run Code Online (Sandbox Code Playgroud)

java android case button void

0
推荐指数
1
解决办法
2339
查看次数

用C#计算Button的颜色

我的程序有问题.我有3个按钮,默认颜色为白色.当我的按钮背面颜色变为红色时,我的程序将计算多少个按钮为红色.我有一个想法使用foreach但它不起作用

Button[] Tombol = new Button[]{B1, B2, B3}
int counterbutton = 0;

foreach (Button Tombol2.BackColor = Color.Red in Tombol) //I have problem here. I don't know how to solve
{
  counterbutton++;
}
Run Code Online (Sandbox Code Playgroud)

c# button

0
推荐指数
1
解决办法
149
查看次数

该按钮不是调用javascript函数

我有一个按钮,我想在点击它时调用一个函数.现在它只是测试.就在我现在运行它时,按钮似乎无法点击开始.

index.html的:

<!DOCTYPE html>
<html>
  <head>
    <title></title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css"/>
    <script type="text/javascript" src="javascript/javascript.js"></script>
  </head>
  <body>
    <h1>
      <img src="#" alt=""/>
    </h1>

    <h3>1. Getting Store categories</h3>
    <button  onclick="getCategories()">Click here to Get Categories.</button> 
    <p></p>

  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

javascript.js:

function getcategories()
{
    alert("TEST");
}
Run Code Online (Sandbox Code Playgroud)

EDDIT:stylesheet.css:

* {
    font-family: Ariel, Verdana, sans-serif;
}

h1 {
    text-align: center;
    color: #fff;
    text-shadow: 0px 1px 0px #999, 0px 2px 0px #888, 0px 3px 0px #777, 0px 4px 0px #666, 0px 5px 0px #555, 0px 6px 0px …
Run Code Online (Sandbox Code Playgroud)

javascript html5 alert function button

0
推荐指数
1
解决办法
59
查看次数