简体   繁体   English

错误 CS1503 参数 1:无法从“NYDStok.BarButtonItem”转换为“DevExpress.XtraBars.BarItem”

[英]Error CS1503 Argument 1: cannot convert from 'NYDStok.BarButtonItem' to 'DevExpress.XtraBars.BarItem'

I want to create a button in C# Devexpress.我想在 C# Devexpress 中创建一个按钮。 This is the area where I want to add the button.这是我要添加按钮的区域。

But when I try to add it I get an error.My code is as below.但是当我尝试添加它时出现错误。我的代码如下。 As soon as the button is clicked, it saves the file with the day, month, year and instant time of that day.单击该按钮后,它会立即保存文件以及当天的日、月、年和即时时间。 But because my button is not visible, these processes are not happening now.但是因为我的按钮不可见,所以这些过程现在不会发生。 I tried to add this button from another project to my own project.我试图将此按钮从另一个项目添加到我自己的项目中。 That's why I need help.这就是我需要帮助的原因。

        void PreviewForm_Shown(object sender, EventArgs e)
    {
        PrintPreviewFormEx form = (PrintPreviewFormEx)sender;
        PrintPreviewBarItem item = (PrintPreviewBarItem)form.PrintBarManager.GetBarItemByCommand(PrintingSystemCommand.ExportFile);

        PopupMenu control = (PopupMenu)((DevExpress.XtraBars.BarButtonItem)(item)).DropDownControl;
        BarButtonItem barItem = new BarButtonItem();
        barItem.ItemClick += barItem_ItemClick;
        barItem.Caption = "TELEGRAM";
        control.AddItem(barItem);


    }
    async void barItem_ItemClick(object sender, ItemCheckEventArgs e)
    {
        DateTime Tarih = DateTime.Today.Date;
        if (vwMain.GetFocusedRowCellValue(clnUHTarih) != null)
            DateTime.TryParse(vwMain.GetFocusedRowCellValue(clnUHTarih).ToString(), out Tarih);



        PdfExportOptions pdfExportOptions = new PdfExportOptions()
        {
            PdfACompatibility = PdfACompatibility.PdfA1b

        };

        string pdfExportFile = @"C:\samet\" + Convert.ToString(DateTime.Now).Replace(".", "").Replace(":", "").Replace(" ", "_") + ".pdf";
        // Export the report.
        rprGunSonu rpr = new rprGunSonu(pConn, Tarih.Date, clsAyarlar.SubeID);
        pt = new ReportPrintTool(rpr);
        rpr.ExportToPdf(pdfExportFile, pdfExportOptions);

PopupMenu.AddItem() expects an object of type DevExpress.XtraBars.BarItem . PopupMenu.AddItem() 需要DevExpress.XtraBars.BarItem类型的 object You're passing it an object of type NYDStok.BarButtonItem (whatever that is).您正在向它传递一个 NYDStok.BarButtonItem 类型的NYDStok.BarButtonItem (不管是什么)。 Your barItem needs to be a DevExpress.XtraBars.BarItem instead.您的barItem需要改为DevExpress.XtraBars.BarItem

For example:例如:

var barItem = new DevExpress.XtraBars.BarItem();
barItem.ItemClick += barItem_ItemClick;
barItem.Caption = "TELEGRAM";
control.AddItem(barItem);

(Note that you'd also need to change your implementation of barItem_ItemClick to use ItemClickEventArgs instead of ItemCheckEventArgs in order to match the event signature.) (请注意,您还需要更改barItem_ItemClick的实现以使用ItemClickEventArgs而不是ItemCheckEventArgs以匹配事件签名。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CS1503 参数 1:无法从 'string' 转换为 'string[*,*]' - CS1503 Argument1: cannot convert from 'string' to 'string[*,*]' 错误CS1503参数1:无法从“ KurseviApp.Kurs”转换为“ KurseviApp.Student” - Error CS1503 Argument 1: cannot convert from 'KurseviApp.Kurs' to 'KurseviApp.Student' 如何解决此错误“错误 CS1503:参数 1:无法从‘void’转换为‘bool’” - How to resolve this error "error CS1503: Argument 1: cannot convert from 'void' to 'bool'" C# 错误 CS1503 参数 1:无法从“字符串”转换为“字符” - C# Error CS1503 Argument 1: cannot convert from 'string' to 'Character' 有限 State 机器的问题“错误 CS1503:参数 1:无法从‘UIManager’转换为‘GameStateAbstract’” - Problem with a Finite State Machine "error CS1503: Argument 1: cannot convert from 'UIManager' to 'GameStateAbstract'" 错误 CS1503:参数 1:无法从“UnityEngine.XR.XRNode”转换为“string” - error CS1503: Argument 1: cannot convert from 'UnityEngine.XR.XRNode' to 'string (Unity3D) 错误 CS1503:参数 2:无法从“浮动”转换为“UnityEngine.Space” - (Unity3D) error CS1503: Argument 2: cannot convert from 'float' to 'UnityEngine.Space' 出现错误 CS1503:“参数 1:无法从 'System.Diagnostics,PerformanceCounter' 转换为 'int' - Getting Error CS1503: "Argument 1: Cannot convert from 'System.Diagnostics,PerformanceCounter' to 'int' CsvWriter、CS1503 参数 2:无法转换 CultureInfo - CsvWriter, CS1503 Argument 2: cannot convert CultureInfo 将文本复制到剪贴板错误CS1503参数2:无法从'string'转换为'System.Windows.Forms.TextDataFormat' - Copying text to clipboard Error CS1503 Argument 2: cannot convert from 'string' to 'System.Windows.Forms.TextDataFormat'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM