与主题标题一样。 我的数据库包含大量辅助表。 想要构建一个下拉列表来选择我要加载内容的表。 此代码...不起作用:
public ListEcoles()
{
InitializeComponent();
List<string> listEcoles = MainWindow._RE.ListEcoles();
foreach (string nomEcole in listEcoles)
listEcole.Links.Add(new Link() { DisplayName = nomEcole, Source = new Uri("/Controles/EcoleControl.xaml", UriKind.Relative) });
listEcole.PreviewMouseLeftButtonUp += ListEcole_MouseLeftButtonUp;
}
private void ListEcole_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
ListBoxItem lbi = e.OriginalSource as ListBoxItem;
if (lbi == null)
{
lbi = FindParent<ListBoxItem>(e.OriginalSource as DependencyObject);
}
if (lbi != null)
{
Link selectedLink = lbi.DataContext as Link;
if (selectedLink != null)
{
string selectedDisplayName = selectedLink.DisplayName;
MessageBox.Show(selectedDisplayName);
}
}
}
private static T FindParent<T>(DependencyObject dependencyObject) where T : DependencyObject
{
var parent = VisualTreeHelper.GetParent(dependencyObject);
if (parent == null) return null;
var parentT = parent as T;
return parentT ?? FindParent<T>(parent);
}
答案 0 :(得分:3)
在mysql中,您可以访问information_schema过滤您的数据库名称
SELECT table_name
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'your_db_name'
and table_name LIKE 'Mytable_%'
and table_type = 'BASE TABLE';