我有一个属性网格,当单击其中一个属性的按钮时,某些字段将被填充.但是属性的集合未被触发.我不知道为什么.
private OptoSigmaSettings dataToGet = new OptoSigmaSettings();
[Editor(typeof(OptoSetupFormEditor), typeof(UITypeEditor))]
[TypeConverter(typeof(ExpandableObjectConverter))]
[Category("Setup")]
public OptoSigmaSettings DataToGet
{
get { return dataToGet; }
set
{
MessageBox.Show("Im here"); //This isnt happening.
dataToGet = value; }
}
[Serializable]
public class OptoSigmaSettings
{
private int duration = 0;
private string direction = "Positive";
private string functionToCall = "Home";
public string FunctionToCall
{
get { return functionToCall; }
set { functionToCall = value; }
}
public int Duration
{
get { return duration; }
set { duration …
Run Code Online (Sandbox Code Playgroud) 我有一个属性网格,将引用一些属性.我想让属性网格中的一个项目成为一个按钮,或者甚至有一个椭圆形按钮,它就像一个普通胜利形式的按钮.
有没有办法做到这一点?
提前感谢您的帮助!
我正在从一个在while循环中的NetworkStream中读取.问题是我看到100%的CPU使用率.有没有办法阻止这种情况发生?
这是我到目前为止:
while (client != null && client.Connected)
{
NetworkStream stream = client.GetStream();
data = null;
try
{
// Check if we are still connected.
if (client.Client.Poll(0, SelectMode.SelectRead))
{
byte[] checkConn = new byte[1];
if (client.Client.Receive(checkConn, SocketFlags.Peek) == 0)
{
throw new IOException();
}
}
if (stream.DataAvailable)
{
//Read the first command
WriteToConsole("Waiting for next command");
data = ReadStringFromClient(client, stream);
WriteToConsole("Received Command: " + data);
}
}
Run Code Online (Sandbox Code Playgroud)
......代码继续......
ReadStringFromClient代码:
private string ReadStringFromClient(TcpClient clientATF, NetworkStream currentStream)
{
int i;
string builtString; …
Run Code Online (Sandbox Code Playgroud) C#的新手,并试图扩大我的能力.我在VB中有这个代码:
Private Sub BreakdownFilesToCompare(ByRef file1BReader As BinaryReader, _
ByRef file2BReader As BinaryReader, _
ByRef firstFile As StandardFormatFile, _
ByRef secondFile As StandardFormatFile)
file1BReader.ReadInt32()
file2BReader.ReadInt32()
firstFile.numberOfSeries = file1BReader.ReadInt32
secondFile.numberOfSeries = file2BReader.ReadInt32
If firstFile.numberOfSeries <> secondFile.numberOfSeries Then
WriteToConsole("The number of Elements the two files do not match...Stopping")
Exit Sub
End If
For i As Integer = 0 To firstFile.numberOfSeries - 1
Dim tempSeriesData1 As New StandardFormatFileSeries
Dim tempSeriesData2 As New StandardFormatFileSeries
tempSeriesData1.standardNumOfElements = file1BReader.ReadInt32
tempSeriesData1.standardSeriesName = GetSeriesName(file1BReader)
tempSeriesData2.standardNumOfElements = file2BReader.ReadInt32
tempSeriesData2.standardSeriesName = …
Run Code Online (Sandbox Code Playgroud) 我试图断开客户端与服务器的连接,但服务器仍然将其视为已连接.我无法找到解决方案,关闭,断开和关闭所有不工作.
我与客户端断开连接并检查服务器的一些代码:
客户:
private void btnDisconnect_Click(object sender, EventArgs e)
{
connTemp.Client.Shutdown(SocketShutdown.Both);
connTemp.Client.Disconnect(false);
connTemp.GetStream().Close();
connTemp.Close();
}
Run Code Online (Sandbox Code Playgroud)
服务器:
while (client != null && client.Connected)
{
NetworkStream stream = client.GetStream();
data = null;
try
{
if (stream.DataAvailable)
{
data = ReadStringFromClient(client, stream);
WriteToConsole("Received Command: " + data);
}
} // So on and so on...
Run Code Online (Sandbox Code Playgroud)
代码中还有更多的写入和读取.
希望你们都能提供帮助.
更新:我甚至尝试通过ref传递TCP客户端,假设存在范围问题和client.Connected即使在读取后仍然为真.出了什么问题?
第二次更新!!:
这是解决方案.先查看并确定是否已连接.
if (client.Client.Poll(0, SelectMode.SelectRead))
{
byte[] checkConn = new byte[1];
if (client.Client.Receive(checkConn, SocketFlags.Peek) == 0)
{
throw new IOException();
}
}
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
public void GetParameterSelectionSet(int wire, int bond, string processProgramPath)
{
string connectionString = "Provider=Microsoft.JET.OLEDB.4.0;" + "data source=" + processProgramPath + ";";
using (OleDbConnection connection = new OleDbConnection(connectionString))
{
connection.Open();
using (OleDbCommand command = new OleDbCommand("SELECT * " +
"FROM BONDS INNER JOIN WIRES on " +
"BONDS.WireID = WIRES.WireID " +
"WHERE (WIRES.OperationOrder = '@WireOrder') AND" +
"(BONDS.OperationOrder = '@BondOrder')", connection))
{
command.Parameters.Add(new OleDbParameter("@WireOrder", OleDbType.Numeric));
command.Parameters.Add(new OleDbParameter("@BondOrder", OleDbType.Numeric));
command.Parameters["@WireOrder"].Value = wire;
command.Parameters["@BondOrder"].Value = bond;
var mytemp = command.ExecuteScalar();
}
} …
Run Code Online (Sandbox Code Playgroud) 如果用户在我的主表单上选择某个项目,我会弹出一个小的登录屏幕.如何让我的代码停止执行直到我的登录表单关闭?
这就是我到目前为止所做的事情.基本上我想要在MyLogin关闭后执行代码.
BMSSplash.MyLogin.Show()
If isLoggedIn Then
BMSSplash.MyBuddy.Show()
Cursor.Current = Cursors.WaitCursor
End If
Run Code Online (Sandbox Code Playgroud) 我有以下代码:
private void SelectRowData(int wire, int bond, string svid)
{
var results = from myRow in PPLoadedData.AsEnumerable()
where
myRow.Field<Int32>("Wires.OperationOrder") == wire &&
myRow.Field<Int32>("Bonds.OperationOrder") == bond
select myRow[svid];
}
Run Code Online (Sandbox Code Playgroud)
我可以看到,当我调试时,结果确实有我期望的单个字符串项.但是,我无法通过我所知的任何方式索引或迭代数据.
我正在寻找的是我可以访问数据的东西.
以下是调试器所说的内容:
名称:( new System.Linq.SystemCore_EnumerableDebugView(results)).Items [0]
价值:700.0
输入:object {double}
PPLoadedData
是一个DataTable
.
提前致谢.
我使用XMLWriter手动创建XML文档.有没有办法把它放在字符串形式,所以我可以把它写到我的数据库?
我在VB.Net编码
我试图插入访问数据库,PK是由DB生成的自动编号.我收到插入语句的语法错误,不知道为什么.如果可能,我想在同一语句中返回自动编号值.
这是我到目前为止所得到的.
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim str As String
Try
cn = New OleDbConnection("Provider=microsoft.Jet.OLEDB.4.0;Data Source=G:\Sean\BMSBonder3_0.mdb;")
cn.Open()
str = String.Format("Insert into Bonder(BonderName, BonderConfig, Date, User) values ('{0}', '{1}', '{2}', '{3}')", addBonder.BonderName _
, xmlString, Date.Now.ToString, Environment.UserName)
MsgBox(str)
cmd = New OleDbCommand(str, cn)
cmd.ExecuteNonQuery()
cn.Close()
Catch ex As Exception
MsgBox(ex.Message)
Return False
End Try
Return Nothing
Run Code Online (Sandbox Code Playgroud)
显然在VB.Net中编码.在查询中,除自动编号字段外,设置所有字段值.
这是来自DLL的代码:
public static bool SendCommand(string command)
{
KillTeraTerm();
try
{
SerialPort portToUse = new SerialPort("COM2");
portToUse.Open();
portToUse.WriteLine(command);
portToUse.Close();
StartTeraTerm();
return true;
}
catch
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我用来引用dll的代码:
Assembly loadedDLL = Assembly.LoadFile(@"G:\PRODUCT VALIDATION GROUP\SOFTWARE VALIDATION\Ranorex Support Files\RTSInterface.dll");
Type rtsObj = loadedDLL.GetType("Oe.RTS.RTSInterface");
Object obj = Activator.CreateInstance(rtsObj);
try
{
rtsObj.InvokeMember("SendCommand", BindingFlags.InvokeMethod | BindingFlags.Static | BindingFlags.Public, null, obj, new object[] { "startbutton" });
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
Run Code Online (Sandbox Code Playgroud)
我知道我还没有使用返回值...只是想知道为什么这不起作用.
第一个异常:Message ="调用目标抛出了异常."
内部异常消息="请求失败"."
DeclaringMethod ='rtsObj.DeclaringMethod'引发了类型'System.InvalidOperationException'的异常
谢谢你的帮助.第一次使用反射,对不起的代码抱歉.
来自VS的堆栈跟踪:Saftey Door …
首先,我主要进行C#,.Net开发,所以如果这是一个愚蠢的问题,请继续.
我正在实现一个Ericcson开源项目,将图像转换为另一种格式.问题是在转换时输出到控制台发生如下...
1 file(s) copied.
Run Code Online (Sandbox Code Playgroud)
我需要禁止弹出的对话框.我只想执行没有输出的系统命令.我想我已经隔离了引起这个问题的代码区域.
void writeOutputFile(char *dstfile, uint8* img, uint8* alphaimg, int width, int height)
{
char str[300];
if(format!=ETC2PACKAGE_R_NO_MIPMAPS&&format!=ETC2PACKAGE_RG_NO_MIPMAPS)
{
fWritePPM("tmp.ppm",width,height,img,8,false);
//PRINTF("Saved file tmp.ppm \n\n");
}
else if(format==ETC2PACKAGE_RG_NO_MIPMAPS)
{
fWritePPM("tmp.ppm",width,height,img,16,false);
}
if(format==ETC2PACKAGE_RGBA_NO_MIPMAPS||format==ETC2PACKAGE_RGBA1_NO_MIPMAPS||format==ETC2PACKAGE_sRGBA_NO_MIPMAPS||format==ETC2PACKAGE_sRGBA1_NO_MIPMAPS)
fWritePGM("alphaout.pgm",width,height,alphaimg,false,8);
if(format==ETC2PACKAGE_R_NO_MIPMAPS)
fWritePGM("alphaout.pgm",width,height,alphaimg,false,16);
// Delete destination file if it exists
if(fileExist(dstfile))
{
sprintf(str, "del %s\n",dstfile);
system(str);
}
int q = find_pos_of_extension(dstfile);
if(!strcmp(&dstfile[q],".ppm")&&format!=ETC2PACKAGE_R_NO_MIPMAPS)
{
// Already a .ppm file. Just rename.
sprintf(str,"move tmp.ppm %s\n",dstfile);
//PRINTF("Renaming destination file to %s\n",dstfile);
}
else
{
// Converting from .ppm to …
Run Code Online (Sandbox Code Playgroud) .net ×9
c# ×8
vb.net ×4
winforms ×3
ms-access ×2
propertygrid ×2
sockets ×2
autonumber ×1
binaryreader ×1
c++ ×1
cpu-usage ×1
database ×1
disconnect ×1
forms ×1
insert ×1
linq ×1
output ×1
ranorex ×1
reflection ×1
sql ×1
system ×1
tcpclient ×1
uitypeeditor ×1
windows ×1
xml ×1