[英]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.