我有一个带有几个文本框和一个按钮的ac #windows窗体应用程序.我想找出具有焦点并对其做一些事情的文本框.我写了下面的代码但当然它不起作用,因为按钮一按下就会得到焦点.
private void button1_MouseDown(object sender, MouseEventArgs e)
{
foreach (Control t in this.Controls)
{
if (t is TextBox)
{
if (t.Focused)
{
MessageBox.Show(t.Name);
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 在xls-fo fop 0.94中使用keep-together和wrap-option ="wrap"会忽略wrap选项吗?有没有办法让它们都起作用?
<fo:table-row border="1pt solid black" keep-together="always">
<fo:table-cell>
<fo:block overflow="scroll" wrap-option="wrap">
This is a long text It is desired that this text be wrapped in the table cell but just can not make it happen!
</fo:block>
</fo:table-cell>
</fo:table-row>
Run Code Online (Sandbox Code Playgroud) 我想知道Antennahouse对Apache FOP的区别和其他功能.
我想使用.net在选定的打印机中打印任何文档,如pdf,word,excel或文本文件.我已成功在默认打印机中进行此类打印.现在唯一的问题是在所选打印机中打印.
这是打印的代码.
public bool Print(string FilePath)
{
if (File.Exists(FilePath)) {
if (ShellExecute((System.IntPtr )1, "Print", FilePath, "", Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32() <= 32) {
return false;
} else {
return true;
}
} else {
return false;
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Autofac 开发一个 Win 表单应用程序,我们在这里解决依赖关系如下:如文档所示
using (var scope = DIConfig.container.BeginLifetimeScope())
{
var us = scope.Resolve<IUsersService>();
usersGrid.DataSource = us.GetUsers();
}
Run Code Online (Sandbox Code Playgroud)
然而,在 Web MVC 项目中,我们可以解决所有的依赖关系,例如
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
Run Code Online (Sandbox Code Playgroud)
这样就不需要每次都解析范围并使用简单的代码
usersGrid.DataSource = us.GetUsers();
Run Code Online (Sandbox Code Playgroud)
我们如何在 Winform 中进行类似的解析,以便不需要使用更多代码?如何解决 Winforms 中的依赖?WinForm有Autofac 集成库吗?
有没有办法在winforms中合并.net的datagridview中的单元格.我想合并一行中的两个或多个单元格.
From Table
A B
_______________
1 A
3 B
6 C
7 C
8 X
9 Y
15 Z
16 R
17 t
23 T
43 e
Run Code Online (Sandbox Code Playgroud)
如何带来这个结果:
Range A Count B
_________________
1-10 6
11-20 3
21-30 1
31-40 1
Run Code Online (Sandbox Code Playgroud)
这可以使用循环完成:
Select Count (* ) from TableA where b between @a and @b
Run Code Online (Sandbox Code Playgroud)
但我想这样做而不使用任何循环是否可能?
几乎所有.net程序集都可以使用Reflection进行解编译.这意味着所有.net产品都是开源的,因为代码可以很容易地被其他开发人员使用.没有办法让我们可以加密代码(至少对某些安全逻辑来说),这样就不会轻易破解或误用.
编辑
老问题winforms .net真的等于开源吗? 编辑时考虑了有关正确使用" 开源 "一词的评论
我使用过 autofac,mvc 4.0。我已经在我的 mvc 4.0 应用程序的 Application_Start 中注册了接口和模块。我还使用了自动连接的属性,例如
protected void Application_Start()
{
//Other codes...
builder.RegisterType<Service>()
.As<IService>()
.InstancePerLifetimeScope()
.PropertiesAutowired());
builder.RegisterControllers(typeof (MvcApplication).Assembly)
.PropertiesAutowired();
...
}
Run Code Online (Sandbox Code Playgroud)
但是在启动类中没有解析依赖,对象始终为 null 。
public class Startup
{
public IService MyService { get; set; }
public void Configuration(IAppBuilder app)
{
MyService.SomeMetod(3, "");
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我希望 MyService 是一个对象,但它不是,所以它总是为空,我做错了什么请帮助。
请注意 di 是在控制器中工作的,它不仅仅在启动类中工作!
我发现一个图像可以存储为一些字符串.举个例子我已经包含了一个带有图像的ms字部分.我用图像保存了一个word文件并将其保存为xml格式.当我打开xml文件时记事本我得到了以下部分.它必须是存储为某些文本流的图像.是否有类似的方法在.net中执行此操作.
<pkg:part pkg:name="/word/media/image1.png" pkg:contentType="image/png" pkg:compression="store">
<pkg:binaryData>
iVBORw0KGgoAAAANSUhEUgAAAMgAAAA2CAMAAAC1HibFAAADAFBMVEWlweL95Mn90qXs8vn7woTi
6/b7unT94sO8oIP93br4okTJjExJgsS9mXT5rVr7xYr4mzaStdz+/v/5qlT3kiT7vnuCqdb7zZv8
1aqXqb5GgMP4nTt6mLpMhMX//Pn/+vT/s1n/4rU+fMH+8eXT4fH1+PyTqsb++PGXl5n3lSpQh8b9
6tVLg8T3iRP6sWO80el5o9OpxOP+7t3+9uz+2rLC1ez+7Nmbut6yyub+9On5pUqQt+P3jh2SmqNE
...Truncated for easy reading...
ex9vtLWG320M9N9gHow3tv8BO9hrVo7LVzgAAAAASUVORK5CYII=
</pkg:binaryData>
</pkg:part>
Run Code Online (Sandbox Code Playgroud)
我试过以下方式
Bitmap bmp = new Bitmap(@"D:/bmp.bmp");
MemoryStream mem = new MemoryStream();
byte[] b = mem.ToArray();
Run Code Online (Sandbox Code Playgroud)
但是它给了我一个字节数组而不是字符.如果它是字符,我可以在很多方面使用它,比如保存xml格式,使用sql insert在一个blob的varchar insead中插入图像.等等
c# ×6
.net ×5
winforms ×3
apache-fop ×2
autofac ×2
xml ×2
xsl-fo ×2
asp.net-mvc ×1
decompiling ×1
group-by ×1
image ×1
printing ×1
security ×1
shellexecute ×1
sql ×1
sqlite ×1
vb.net ×1