Skip to content

A library that develops WinForms quickly. Metroit.Windows.Forms has been extended. The target framework is .NET 4.5.

License

Notifications You must be signed in to change notification settings

takiru/VanishFlare

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet

Japanese

VanishFlare

A library that develops WinForms quickly.
Metroit.Windows.Forms has been extended.
The target framework is .NET 4.5.

Flow values to other controls

You can use the FieldControlMaps property to set values from the object selected by the Metroit extension CustomAutoCompleteBox to other controls.

  • VfMapTextBox
  • VfMapLimitedTextBox
  • VfMapNumericTextBox

Property

Name Meaning
FieldControlMaps StringFieldControlMap[]

StringFieldMap

  • Control
    • Control for which you want to set the value of FieldName.
  • FieldName
    • Property name of the value to be set for the object selected by CustomAutoCompleteBox.

How to use

In the example below, when selecting a value from input candidates for vfMapTextBox1, set the value of Column2 as Text of label1.

vfMapTextBox1.FieldControlMaps = new StringFieldControlMap[] {
    new StringFieldControlMap() { Control = label1, FieldName = "Column2" }
};

var dt = new DataTable();
dt.Columns.Add("Column1");
dt.Columns.Add("Column2");

var row = dt.NewRow();
row["Column1"] = "aaa1 disp";
row["Column2"] = DateTime.Now;
dt.Rows.Add(row);

row = dt.NewRow();
row["Column1"] = "aaa2 disp";
row["Column2"] = new DateTime(2010, 10, 12);
dt.Rows.Add(row);

vfMapTextBox1.CustomAutoCompleteBox.DataSource = dt;

In the following example, when selecting a value from input candidates for vfMapTextBox1, the value of Sample2Data in the EfSample2 class is set as Text of label1.
You can access the interior of the object hierarchy by using "->".

public class EfSample1 : DbContext
{
    [Key]
    public string Sample1Data { get; set; }
    public DbSet<EfSample2> EfSample2 { get; set; }
}

public class EfSample2 : DbContext
{
    [Key]
    public string Sample2Data { get; set; }
}
vfMapTextBox1.FieldControlMaps = new StringFieldControlMap[] {
    new StringFieldControlMap() { Control = label1, FieldName = "EfSample2->Sample2Data" }
};

var efList = new List<EfSample1>();
var efSample1 = new EfSample1()
{
    Sample1Data = "Sample1Data"
};
efSample1.EfSample2.Add(new EfSample2()
{
    Sample2Data = "Sample2Data"
});
efList.Add(efSample1);

vfMapTextBox1.CustomAutoCompleteBox.DataSource = efList;

If the control to be mapped is a CheckBox, the Checked property is set according to the following criteria.

Value Setting value
"true" true
"false" false
"0" false
"false", "0"以外 true
0 false
0以外 true

If the control to be mapped is a RadioButton, the Checked property is set according to the following criteria.

Value Setting value
"true" true
"false" false
"0" false
"false", "0"以外 true
0 false
0以外 true

When mapping control is ComboBox, Text property or SelectedItem property are set according to the following criteria.

Condition Setting property
DataSource == null Text
DataSource != null SelectedItem

In the designer, select FieldName from class properties

By inheriting the classes below, you can realize the method of selecting the property of any class.
Properties must match BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty.

  • VfTextBoxBase
  • VfLimitedTextBoxBase
  • VfLNumericTextBoxBase
  1. Prepare the target class.
    public class TestListItem
    {
        public string Column1 { get; set; }
        public DateTime Column2 { get; set; }
    }
  2. Prepare a class for mapping properties.
    public sealed class TestListItemFieldControlMap : Vf.Windows.Forms.FieldControlMapBase<TestListItem> { }
  3. Prepare a control that uses the mapping class.
    public class TestListItemTextBox : VfTextBoxBase<TestListItemFieldControlMap> { }
  4. If you check the FieldControlMasps of TestListItemTextBox in the designer, you can see that FieldName is selectable from the class properties.
    prop

About

A library that develops WinForms quickly. Metroit.Windows.Forms has been extended. The target framework is .NET 4.5.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages