无论表单是最大化,最小化还是FormWindowState为Normal,调用Form.Visible都将返回true.
我想知道的是如何判断表单是否打开但是隐藏在另一个应用程序窗口后面.
如果是这种情况,我想把它带到前面,实际上让用户可以看到它.
我尝试了BringToFront()方法,但它没有用.我也试过调用Show()方法但是如果表单在另一个应用程序的窗口后面,它仍然是那样.
我发现问题的唯一解决方法是将Form的FormWindowState设置为Minimized/Maximized然后正常,但这有点像黑客并且看起来不太好.
有人能告诉我如何判断表格是否在另一个窗口后面以及如何将其带到前面?
如何检查表单是否已打开,以及表单是否已打开以关闭表单?
我尝试了下面的代码,测试了一些代码,但它仍然表示,即使我知道它是:
foreach(Form a in Application.OpenForms)
{
if (a is YouLikeHits_Settings)
{
// About form is open
MessageBox.Show("form open");
break;
}
// About form is not open...
MessageBox.Show("form not open");
break;
}
Run Code Online (Sandbox Code Playgroud) 嘿所以我有一个文本框/ FormControl,它应该在this.state中更新json中的一个字段.我想知道是否有更好的方法来改变?
<FormControl
type='text'
placeholder='enter'
defaultValue={this.state.form.name}
onChange={this.handleChange.bind(this, 'name')}
/>
</FormGroup>
Run Code Online (Sandbox Code Playgroud)
`
handleChange(change, event) {
var toChange = this.state.form;
toChange[change] = event.target.value;
this.setState({form: toChange});
}
Run Code Online (Sandbox Code Playgroud) 我正在使用反应形式方法。我有一个具有对应的formControl对象的输入字段,并且在键入时我正在对值进行格式化-使所有输入大写。
那当然工作得很好-在视图和formControl中也会更新该值。
The issue is That I would like to send to server the original value and not the formmated value (uppercase)
So I need something like value, and value for display in the formControl object.
See plunker - formatting value formControl
template:
<input type="text"
class="form-control"
(blur)="handleOnBlur($event)"
(input)="onChange($event)"
formControlName="name">
Run Code Online (Sandbox Code Playgroud)
model:
valueForModel: string;
valueForDisplay: string;
public myForm: FormGroup;
onChange(event) {
const value = event.target.value;
this.valueForModel = value;
this.valueForDisplay = value.toUpperCase();
event.target.value = this.valueForDisplay;
}
handleOnBlur(event) {
consol.log(this.valueForModel);
// Herer I'm calling …Run Code Online (Sandbox Code Playgroud) model-view-controller model reactive-programming form-control angular
我想在 Angular 5 中创建一个自定义选择输入控件。我有一个实现 SelectControlValueAccessor 的组件。当我实现如下所示的课程时。它在代码注释中给出了错误。
import { Component, Input, forwardRef, SimpleChanges, OnChanges } from '@angular/core';
import { SelectControlValueAccessor } from '@angular/forms';
import { SELECT_VALUE_ACCESSOR } from '@angular/forms/src/directives/select_control_value_accessor';
@Component({
selector: 'select-input',
template: ` `,
providers: [
{
provide: SELECT_VALUE_ACCESSOR,
useExisting: forwardRef(() => SelectInputComponent),
multi: true
}
]
})
/*
[ts]
Class 'SelectInputComponent' incorrectly implements class 'SelectControlValueAccessor'. Did you mean to extend 'SelectControlValueAccessor' and inherit its members as a subclass?
Property '_renderer' is missing in type 'SelectInputComponent'.
class SelectInputComponent
*/
export …Run Code Online (Sandbox Code Playgroud) 我正在使用表单控件,这是我的html组件的代码
<mat-form-field>
<mat-select placeholder="Toppings" [formControl]="toppings" multiple>
<mat-option *ngFor="let topping of toppingList" [value]="topping">{{topping.value}}</mat-option>
</mat-select>
</mat-form-field>Run Code Online (Sandbox Code Playgroud)
我的ts文件是
export class SelectMultipleExample {
toppings = new FormControl();
toppingList: any[] = [
{ id:1,value:"test 1"},
{ id:2,value:"test 2"},
{ id:3,value:"test 4"},
{ id:4,value:"test 5"},
{ id:5,value:"test 6"},
{ id:6,value:"test 7"}
];
constructor(){
this.bindData();
}
bindData(){
const anotherList:any[]=[
{ id:1,value:"test 1"},
{ id:2,value:"test 2"}
]
this.toppings.setValue(anotherList)
}
}Run Code Online (Sandbox Code Playgroud)
我想为mat select设置默认值,如何实现这一点的任何帮助都会很棒。我想设置多个默认值。
我正在尝试在 formarray 中的 formcontrol 上实现材料自动更正,但是当我尝试访问 ts 文件中的 formcontrol 时,它无法访问它。谁能帮帮我吗。
html 文件:
<div formArrayName="applicants">
<div *ngFor="let applicant of appForm.controls.applicants.controls; let i=index; let last = last">
<div [formGroupName]="i">
<div class="row">
<label for="applicant_short_name" class="col-sm-3 form-control-label">Applicant {{i+1}}</label>
<div class="col-sm-7">
<div class="form-group">
<!-- <input type="text" formControlName="applicant_short_name" class="form-control" id="inputFirstName" placeholder="Applicant"> -->
<!-- <mat-form-field > -->
<input type="text" class="form-control" id="inputFirstName" placeholder="Applicant" [matAutocomplete]="auto" [formControlName]="applicant_short_name">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let state of filteredNames | async | slice:0:3" [value]="name">
<span>{{ name }}</span>
</mat-option>
</mat-autocomplete>
<!-- </mat-form-field> -->
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
.ts 文件: …
大家好,我有一个具有一组角色的 Formarray。在编辑期间,它会动态删除并在该表单数组中添加角色,直到这里一切正常,但是当我提交表单时,它会引发错误并且页面会刷新。
错误:TypeError:无法读取 null 的属性“updateOn”
我有一个使用ActiveX选项按钮可以正常工作的代码.但是,我希望宏也能在Mac上运行,所以我试图用表单控件替换我的ActiveX控件.使用ActiveX,我必须做的就是检查我的两个选项按钮之一是否被选中:
Sub OptionButton1_Click
If OptionButton1.Value = true then
(action...)
End if
End sub
Run Code Online (Sandbox Code Playgroud)
我一直在尝试在Google上找到Form Controls的等价物,但每次我得到一个:
对象必需的错误
非常感谢你的答案@ L42和@Sai Nishank!现在如果我想检查OptionButton_Click,如果其他组中的选项按钮为真,该怎么办?我尝试了这种语法,但我收到一条错误消息:"编译错误方法或数据未找到"
Sub USDButton_Click()
MsgBox "USD"
If Sheet1.BTUButton = True Then
(action1)
End If
If Sheet1.kWhButton = True Then
(action2)
End If
Run Code Online (Sandbox Code Playgroud)
我不确定BTUButton是否是正确的按钮名称,但我不在哪里检查,表单控件没有那么方便的"右键单击>属性",如ActiveX
我在表单上使用ng-select,但现在我想将其特定配置包装在自定义组件上。问题是我正在使用FormArray包含其中几个的 a,以下面的方式:
this.profileForm = this.formBuilder.group(
{
...
linkedRoles: this.formBuilder.array([])
}
);
Run Code Online (Sandbox Code Playgroud)
这linkedRoles由下一个填充FormGroup:
let fgRoles: FormGroup;
for (let i = 0; i < this.userRoles.length; i++) {
fgRoles = this.formBuilder.group({
activeRole: [{ value: null }],
roles: [{ value: null }]
});
this.linkedRoles.push(fgRoles);
this.linkedRoles.controls[i].setValue({
activeRole: this.userRoles[i].role,
roles: this.extractUserRoles(this.userRoles[i])
});
Run Code Online (Sandbox Code Playgroud)
为了简单起见,还创建了 getter:
get linkedRoles(): FormArray {
return <FormArray>this.profileForm.get("linkedRoles");
}
Run Code Online (Sandbox Code Playgroud)
之后,在我的模板中,我使用了这个效果完美的组合:
<form [formGroup]="profileForm">
...
<table>
...
<tbody>
<tr formArrayName="linkedRoles"
*ngFor="let usuR of userRoles;
let idx = index" …Run Code Online (Sandbox Code Playgroud)