简体   繁体   中英

How to show checkbox as checked in SAP B1 UserForm?

namespace BordroPlus
{
    [FormAttribute("BordroPlus.Puantaj", "Puantaj.b1f")]
    class Puantaj : UserFormBase
    {
        SAPbouiCOM.Form oForm;
        .....

        CheckBox4.ValOn = "Y";
        CheckBox4.ValOff = "N";
        oForm.DataSources.UserDataSources.Add("UD_4", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 1);
        CheckBox4.DataBind.SetBound(true, "", "UD_4");

       // this sets the checkbox to checked
        oForm.DataSources.UserDataSources.Item("UD_4").Value = "Y"; `I have created an user form and tabcontrol in the form. Then i create a check box in the tab.

How can i start the checkbox as checked?

Thats my code. I am using C# in Visual Studio.

Regarding Teta's answer,you would initialize ValOn and ValOff like this:

    CheckBox0.ValOn = "Y";
    CheckBox0.ValOff = "N";

You also need to setup a DataSource for the Checkbox for it to work properly:

    oForm.DataSources.UserDataSources.Add("CheckboxDS", BoDataType.dt_SHORT_TEXT, 1);
    CheckBox0.DataBind.SetBound(True, "", "CheckboxDS");

    // this sets the checkbox to checked
    oForm.DataSources.UserDataSources.Item("CheckboxDS").Value = "Y"; 

创建复选框时,尝试设置valOn和valOff

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM