我像这样填充我的 WPF ComboBox
foreach (Function fx in XEGFunctions.GetAll())
{
ComboBoxItem item = new ComboBoxItem();
item.Content = fx.Name;
item.ToolTip = fx.Signature;
//item.( some property ) = fx.FunctionValue;
cmbBoxTransformation.Items.Add(item);
}
cmbBoxTransformation.SelectedIndex = 0;
Run Code Online (Sandbox Code Playgroud)
如何为每个 ComboBoxItem 设置不同的值。
有没有办法以 .Net 语言创建自定义控件以在 MS Access 2010 中使用?我有一个程序正在使用子窗体来尝试模拟控件,但它确实运行得不太好。如果我能够用 C# 或 VB.Net 或其他任何东西创建自定义控件并将其导入 Access,我的生活会容易得多。这可能吗?
我不想更改滑块的整个模板,只想更改滑块的刻度和轨道。
我希望轨迹栏的外观应该是这样的:
滑块的背景颜色必须是黑色,轨道的颜色必须是灰色,拨片的颜色也必须是灰色。
这个任务要怎么做呢?
我想将 ChartControl 保存到图像中而不将其显示在屏幕上。
\n\nvar theChart = new Chart();\nvar theSeries = new Series("values");\ntheSeries.IsVisibleInLegend = false;\ntheChart.Series.Add(theSeries);\ntheSeries.Points.AddXY(1, 1);\ntheSeries.Points.AddXY(2, 2);\ntheSeries.Points.AddXY(3, 3);\ntheChart.SaveImage(@"D:\\T\xc3\xa9l\xc3\xa9chargements\\HiddenChart4.png", ChartImageFormat.Png);\nRun Code Online (Sandbox Code Playgroud)\n\n然后我得到一张空白图片。我认为这是因为控件不是油漆。是否可以 ?
\n我正在尝试为按钮创建样式,特别是更改 IsMouseOver 样式(必须通过控件模板覆盖它)。我正在尝试这段代码(我必须使用 c#,没有 xaml),但按钮只是变成黄色,IsMouseOver 没有做任何事情。
private void CreateElement(int i)
{
UIElementOut[i] = new Button();
var uiElement = (Button)UIElementOut[i];
uiElement.Width = 100;
uiElement.Height = 100;
uiElement.VerticalAlignment = VerticalAlignment.Center;
uiElement.HorizontalAlignment = HorizontalAlignment.Center;
uiElement.Content = TextIn[i];
uiElement.FontFamily = new FontFamily(FFontInput[i]);
uiElement.FontSize = Convert.ToDouble(FontSizeIn[i]);
Style MyButtonStyle = new Style();
ControlTemplate templateButton = new ControlTemplate(typeof(Button));
FrameworkElementFactory elemFactory = new FrameworkElementFactory(typeof(Button));
elemFactory.Name = "myButton";
elemFactory.SetValue(Button.BackgroundProperty, Brushes.Yellow);
templateButton.VisualTree = elemFactory;
elemFactory.AppendChild(new FrameworkElementFactory(typeof(ContentPresenter)));
Trigger templateTrigger = new Trigger { Property = Button.IsPressedProperty, Value = true };
templateTrigger.Setters.Add(new …Run Code Online (Sandbox Code Playgroud) 我一直在尝试让组合框使用表的第一列作为其范围输入,但它似乎什么也没做。
前任。
sheet1.ComboBox1.ListFillRange = "table1"
sheet1.ComboBox1.ListFillRange = "table1[Column 1]"
Run Code Online (Sandbox Code Playgroud)
两者都不起作用。即使使用表单 ComboBox 而不是 activeX 并将“table1”或“table1[Column 1]”作为输入范围也是如此。我还尝试在字符串的开头添加“=”(“=table1”等)。
然后我决定命名表范围,因为使用 .ListFillRange 时其他命名范围可以工作:
sheet1.ComboBox1.ListFillRange = "RangeName"
Run Code Online (Sandbox Code Playgroud)
这也不起作用(我认为因为命名范围只是对我最初尝试的同一事物的引用)。
那么我是否只需要制定一个正常的公式来查找第一列所在的范围,或者我是否遗漏了某些内容?(这确实看起来应该是一个功能,因为它很简单,但我想没有什么比我们希望的那么简单)
我想每 5000 毫秒更新一次表单中标签的文本,我一直在尝试使用计时器,但它不起作用,我不知道为什么。这是我正在使用的代码:
private void Form1_Load(object sender, EventArgs e)
{
openRequests();
System.Timers.Timer aTimer = new System.Timers.Timer();
aTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
aTimer.Interval = 20000;
aTimer.Enabled = true;
}
private void OnTimedEvent(object source, ElapsedEventArgs e)
{
codeComboBox.Items.Clear();
try
{
connectionDB.Open();
String query = "";
query = "SELECT GMKEY0 FROM SAM_FILNAS.EGESM1F0 WHERE GMSTX0 = '0' OR GMSTX0 = 'P' ";
daMAT = new OleDbDataAdapter(query, connectionDB);
dsMAT = new System.Data.DataSet();
daMAT.Fill(dsMAT, "sam_filnas.EGESM1F0 ");
foreach (System.Data.DataTable t in dsMAT.Tables)
{
foreach (System.Data.DataRow r in t.Rows) …Run Code Online (Sandbox Code Playgroud) 感谢您的回答和评论。我选择了我选择的答案,因为它允许我继续使用,CEdit只需对代码进行一些小的更改。然而,所考虑的解决方案CMFCMaskedEdit在测试时似乎也有效。如果您选择使用该解决方案,请确保在初始化时为对象应用正确的功能,例如SetValidChars等!:) 再次谢谢大家
我正在使用 Visual Studio Professional 2017 C++ 和 MFC
CEdit我的 MFC 项目中有一个对象,该对象EDITTEXT在我的.rc文件中也有一个控件。
该CEdit对象将由输入关键字的用户进行编辑,我将使用该关键字执行某些操作,即查找包含该关键字的文件。
当然,由于我的任务,我不能允许以下chars: \ / : * ? " < > |,因为这些chars 不允许出现在文件或文件夹名称中。
我该怎么做才能阻止用户将这些字符输入到CEditBox. 实际上,char我只需要:A-Z、a-z、0-9和_。
另一种规格:不,regex请!理想情况下,答案将使用我可能忽略的Control(我看这里)或function(我看这里)。
如果没有解决方案,我会回到这个:
char我将检查用户输入的文本中是否存在这些内容。如果没有,那就太棒了,没什么可担心的!如果是,那么我将返回一个错误:)
先感谢您 !:D
我有一个WIN32所有者绘制的静态控件,使用两个源图像(填充和未填充)绘制进度条.在初始抽奖中效果很好:
case WM_DRAWITEM:
{
DRAWITEMSTRUCT* draw = (DRAWITEMSTRUCT*)lparam;
// Manually draw the progress bar.
if( draw->hwndItem == hwndProgress )
{
// Progress bar is 526 pixels wide.
int left = progressPercent * 526 / 100;
// Paint sections of window with filled and unfilled bitmaps
// based on progress bar position.
HDC hdcMem = ::CreateCompatibleDC(draw->hDC);
::SelectObject(hdcMem, hBmpProgressFull);
::BitBlt(draw->hDC, 0, 0, left, 36, hdcMem, 0, 0, SRCCOPY);
::DeleteDC(hdcMem);
HDC hdcMem2 = ::CreateCompatibleDC(draw->hDC);
::SelectObject(hdcMem2, hBmpProgressEmpty);
::BitBlt(draw->hDC, left, 0, 526-left, 36, hdcMem2, left, …Run Code Online (Sandbox Code Playgroud) 我对WPF和.Net编程一般都是新手.我已下载此源代码.
现在,它有一个包含Paris.Controls csproj的解决方案.
这最初是为Silverlight而制作的,当我尝试将referance添加到这些控件的输出dll时,我收到一个错误:
Error 1 Unknown build error,
'Cannot resolve dependency to assembly
'System.Windows, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e'
because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies
must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.
Line 9 Position 80.' C:\Users\Eric\Documents\Visual Studio
2010\Projects\WpfApplication1\WpfApplication1\MainWindow.xaml 9 80
WpfApplication1
Run Code Online (Sandbox Code Playgroud)
经过一段谷歌搜索,我发现它最喜欢,因为Silverlight - WPF转换.Silverlight使用与WPF不同的依据.我认为这有点愚蠢,因为据我所知,Silverlight是WPF的减法,但没关系.
所以我的问题是我应该怎么做以及如何做?我应该编辑Paris.Controls并使其WPF可用吗?改变参考和类似的东西?如果这就是我应该做的,我该怎么做?如果没有,我的选择是什么?
埃里克,请帮助你们,真诚的你们