我想基于 Private Declare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Sub PrintAttachments(oMail As Outlook.MailItem)
Dim colAtts As Outlook.Attachments
Dim oAtt As Outlook.Attachment
Dim sFile As String
Dim sDirectory As String
Dim sFileType As String
sDirectory = "C:\Users\USER\Desktop\PDFS\Print\"
Set colAtts = oMail.Attachments
If colAtts.Count Then
For Each oAtt In colAtts
sFileType = LCase$(Right$(oAtt.FileName, 4))
Select Case sFileType
' Add additional file types below followed by comma
Case ".pdf"
sFile = sDirectory & oAtt.FileName
oAtt.SaveAsFile sFile
oMail.PrintOut
ShellExecute 0, "print", sFile, vbNullString, vbNullString, 0
End Select
Next
End If
End Sub
选择在一个'DataGrid'中显示不同的DataSource
(SQL)查询。我是通过查看Menu
来咆哮错误的树吗?如何实施?
修改
我终于找到Changing user control on list selection这似乎很好地回答了我的问题,或者至少修改了我的问题。因此,UserControl
将列出所有可用的“部件”。另一个Menu
具有Menu
,其对应于位置,并且最终对应于每个位置处的所述部件的库存。目前,我正在为每个MenuItems
使用点击处理程序,并为部件和每个位置创建特定MenuItem
的新实例。
UserControl
和
private void menuParts_Click(object sender, RoutedEventArgs e)
{
dgRoot.Children.Clear();
UserControl control = new ucParts();
this.dgRoot.Children.Add(control);
this.Title = "Inventory Manager - Parts";
}
我现在的问题是,我可以创建一个可重复使用的UserControl模板,点击处理程序可以将位置名称提供给?数据以相同的方式显示,格式化,使用等,它最终只是不同的基础DataSource查询。
答案 0 :(得分:0)
你好像可以做到这一点。只需在我的案例中创建通用用户控件Grid
。
MainWindow.xaml
<DockPanel>
<Menu DockPanel.Dock="Top" Name="menuMain" Height="27" HorizontalAlignment="Stretch" VerticalAlignment="Top" ScrollViewer.VerticalScrollBarVisibility="Disabled" >
<MenuItem Header="Parts">
<MenuItem Name="menuParts" Header="Parts" Click="menuParts_Click"/>
<Separator />
<MenuItem Name="addPart" Header="Add Part" Click="addPart_Click" />
</MenuItem>
<MenuItem Header="Inventory">
<MenuItem Name="menuBrady" Header="Brady" Click="menuBrady_Click"/>
<MenuItem Name="menuCO" Header="Community" Click="menuCO_Click"/>
<MenuItem Name="menuPoly" Header="Poly" Click="menuPoly_Click"/>
<MenuItem Name="menuSG1" Header="SG1" Click="menuSG1_Click"/>
<MenuItem Name="menuWS" Header="West Shore" Click="menuWS_Click"/>
</MenuItem>
</Menu>
<Grid Name="dgRoot" />
</DockPanel>
然后如上面的Click
处理程序所示,使用它们!