我希望有一个人可以帮助我。我有一个相对简单的程序,它从实体查询数据并将查询绑定到,dataGridView1
但我遇到了以下错误,我试图解决超过 30 分钟没有进展。
System.NotSupportedException: 'LINQ to Entities 无法识别方法 'System.Windows.Forms.DataGridViewCell get_Item(Int32)' 方法,并且此方法无法转换为存储表达式。
using (var context = new myContext())
{
var query = context.mySoftWare
.Where(s => s.Software.Contains(dataGridView2.SelectedRows[0].Cells[0].Value.ToString()))
.Select(r => new {r.SID, r.Software,r.Vendor,r.Version });
dataGridView1.DataSource = query.ToList();
}
Run Code Online (Sandbox Code Playgroud) 我有一个pictureBox2
并且它设置为zoom
,我试图找出如何通过Mouse.Click
on获取图像上的真实 x,y 像素位置pictureBox2
。但我尝试了我所知道的 3 种可能的想法: without/with PointToClient
,PointToScreen
但我永远无法做到正确。
private void pictureBox2_Click(object sender, EventArgs e)
{
MouseEventArgs me = (MouseEventArgs)e;
txtpictureHeight.Text =(
(OriginalImage.GetImageHeight()*me.Location.Y)/ pictureBox2.Image.Height).ToString();
txtpictureWidth.Text = (
(OriginalImage.GetImageWidth()* me.Location.X)/ pictureBox2.Image.Width).ToString();
}
Run Code Online (Sandbox Code Playgroud)
一定有一些我需要注意的因素,所以我想使用上面的双重结果,然后我关闭了,但我的测试图像 (1371x2221) 的高度仍然有 80px。当我使用时Zoom
,我的上有 2 个额外的空间pictureBox2
我有3个列表,它们的值是动态获得的
List<double> input = new List<double>();
List<double> time = new List<double>();
List<double> censor = new List<double>();
Run Code Online (Sandbox Code Playgroud)
如何double[][]
以有效的方式转换/合并为以下示例?
double[][] example =
{
// input time censor
new double[] { 50, 1, 0 },
new double[] { 70, 2, 1 },
new double[] { 45, 3, 0 },
new double[] { 35, 5, 0 },
new double[] { 62, 7, 1 },
new double[] { 50, 11, 0 },
new double[] { 45, 4, 0 },
new double[] { 57, …
Run Code Online (Sandbox Code Playgroud) 这可能是非常基本的C#问题,因为我只研究C#自己有些东西我没有逻辑可以开始.
我有一个类CustomerSite
与string Customer {get;set}
和string Site {get;set;}
我创建一个列表 List<CustomerSite> listCustomerSite= new List<CustomerSite>();
假设,我有一个包含以下数据的列表
SAMSUNG CHINA
SAMSUNG AMERICA
SAMSUNG AFRICA
LG CHINA
APPLE AMERICA
APPLE CHINA
Run Code Online (Sandbox Code Playgroud)
我想有一个串联的字符串
string Result = "APPLE (AMERICA, CHINA), LG (CHINA), SAMSUNG (AFRICA, AMERICA, CHINA)"
我怎么能这样做?
我的想法是使用字典来保存不同客户的列表并将网站添加到字符串但我仍然不知道如何处理排序 (AFRICA --> AMERICA --> CHINA)
Dictionary<string, int> dictCustomer = new Dictionary<string, int>();
foreach (var i in listCustomerSite)
{
if (!dictCustomer.ContainsKey(i.Customer))
{
dictCustomer.Add(i.Customer, 0);
Result = Result + "," + "i.Customer" + "( i.Site) ";
}
else …
Run Code Online (Sandbox Code Playgroud)