|
And in 7.x we now can have:
public static async Task Main(string[] args)
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Don't forget the other new options:
Task Main();
Task<int> Main();
Task<int> Main(string[] args);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am trying to update locations of controls in a vertically scrollable panel. When the panel is not scrolled it works just fine, but when it is scrolled it doesn't work at all.
I have a procedure that returns a Y value for the item. I then modify that number like so:
y = y - (PanelList[panelNumber].VerticalScroll.Value);
But this does not seem to place it correctly. This is true if I add this value as well. It is also true if I use: y = y - (PanelList[panelNumber].AutoScroll.Y);
Any help appreciated.
|
|
|
|
|
1. WinForms ? WPF ? or ... ?
2. PanelList[panelNumber] : a list of Panels each of which is ?
3. the normal use of a scrolling Panel is so you avoid moving its contained Controls manually: what are you trying to achieve ?
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
This is a list of panels each of which I add lines of controls to. I need to add new lines dynamically as each represents information that the user can add or delete.
Is there a way to determine where to place controls based on how the panel is scrolled?
FC
|
|
|
|
|
Until you answer the first question (WPF or Windows Forms or WHAT?), you are not going to get much help.
And you need to be more clear about you want to accomplish; from a user point of view.
There is more than one way to accomplish something; some better than others. If you are having a lot of issues, it's probably the "wrong" solution.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Sorry, I didn't see that question. It is Winforms. I must have read it when I was tired---I thought you were asking what I was trying to do.
Best,
FC
|
|
|
|
|
Member 12074849 wrote: a list of panels each of which I add lines of controls to. I need to add new lines dynamically I'm still not clear on what the problem is here: I assume you know at any time which panel in the list of panels you want to add controls to ... I assume you know how to add controls at run-time.
Where the controls you add at run-time show up in the panel you have added them to is up to you:
1. you can position them by setting the 'Location property
2. you can position them by setting the 'Dock property, ... after you add them ... using 'BringToFront or 'SendToBack to position them first or last in their host panel's z-order.
So, try to clarify what you are doing a bit more.
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Hi,
your description isn't really clear. If what you need is viewing a tall (possibly growing) panel through a limited and fixed "opening" in a WinForm, then my article WinForms AutoScroll Experiment[^] may well apply. If so, you don't need to worry about the scrolling while populating the tall panel at all, it is all automatic, just think about the tall Panel and put the Controls on it where you want them.
On the other hand I probably would not be using a tall and growing panel at all, I much prefer using a ListBox where each item could be a Panel holding some Controls. And then you add a Panel to the ListBox.Items whenever you need to. The big problem now is to get the ListBox paint its content...
You might be interested in FlowLayoutPanel class[^].
Hope this helps.
modified 24-Jul-18 14:14pm.
|
|
|
|
|
Hello Everybody,
I am writing a sender and receiver application, sender in C#,WPF and receiver in C# WinForms. In sender, will be having a list of task to do, which will be sent to multiple receivers running in multiple systems.
Here is the code in Sender
for (int j = 0; j < tmpfilled.Count; j++)
{
Thread thFromReceiver = new Thread(new ThreadStart(thFromReceiverFunction));
thFromReceiver.Start();
}
//Body of the thFromReceiverFunction()
public void thFromReceiverFunction()
{
try
{
TcpClient client = new TcpClient();
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip_address), portNo);
client.Connect(serverEndPoint);
Thread readThreadRec = new Thread(new ParameterizedThreadStart(readFromReceiver));
Thread writeThreadRec = new Thread(new ParameterizedThreadStart(writeToReceiver));
readThreadRec.Start(client);
writeThreadRec.Start(client);
}
catch(Exception ex)
{
}
In Receiver,
TcpListener tcpListener = new TcpListener(IPAddress.Any, portNo);
tcpListener.Start();
while (true)
{
TcpClient client = tcpListener.AcceptTcpClient();
Thread readThread = new Thread(new ParameterizedThreadStart(read_thread));
readThread.IsBackground = true;
Thread writeThread = new Thread(new ParameterizedThreadStart(write_thread));
writeThread.IsBackground = true;
readThread.Start(client);
writeThread.Start(client);
readThread.Join();
writeThread.Join();
client.Close();
}
My problem is, if I am sending to single receiver, everything is working fine. If multiple receivers are running in multiple systems, then, ipaddress which I am sending the request, shows right, but whichever the client receives the first request, all other requests are going to the same client, even though I am sending to different ipaddress (through thFromReceiverFunction() funtion).
I think I explained the issue properly, if not please let me know.
Thanks in advance.
Regards,
Gopinath.
|
|
|
|
|
You have shown all the code related to receivers, but it is the sender that is causing the problem. Please edit your question and show the problem code.
|
|
|
|
|
Hello Richard,
Thanks for your reply.
First two session in earlier post is the code from sender. Here are the code for the functions mentioned in the thread.
public void readFromReceiver(object clients)
{
ASCIIEncoding encoder = new ASCIIEncoding();
TcpClient client = (TcpClient)clients;
NetworkStream clientStream = (client).GetStream();
byte[] msg_type = new byte[1];
bool flag = false;
while(!flag)
{
try
{
int bytesRead = 0;
bytesRead = clientStream.Read(msg_type, 0, 1);
int msg = (int)(msg_type[0]);
string retVal = "";
if (msg == 3)
{
retVal = receiveString(clientStream);
}
}
catch(Exception ex)
{
}
}
}
public void writeToReceiver(object clients)
{
ASCIIEncoding encoder = new ASCIIEncoding();
TcpClient client = (TcpClient)clients;
NetworkStream clientStream = (client).GetStream();
bool flag = false;
while(!flag)
{
while (nQReceiveProjName.Count > 0)
{
try
{
string cmdToPass = fnGetXMLString(nQReceiveProjName[0]);
nQReceiveProjName.RemoveAt(0);
sendCommand(clientStream, 5);
sendString(clientStream, cmdToPass);
}
catch(Exception ex)
{
}
}
}
}
In both the cases, client remote end point is holding the ip address of the client in which the first request is received.
Regards,
Gopinath.
|
|
|
|
|
I don't see anything anywhere where you are storing or using an IP address. Once a socket connection is established between server and client, that socket remains open until closed by either end. Each message using the correct socket endpoint will be sent to the correct client. Google for "client server C#" to see other examples.
|
|
|
|
|
Here is where I am using the ip address to send the request.
IPEndPoint serverEndPoint = new IPEndPoint(IPAddress.Parse(ip_address), portNo);
client.Connect(serverEndPoint);
Let me check in google also as you mentioned.
Thanks again.
Regards,
Gopinath.
|
|
|
|
|
You only do that once, when the client first connects. From then on you must use just the socket that is returned on the connection.
|
|
|
|
|
Hello Richard,
There was an issue from my side. While sending the request (writetosender() function), I am not segregating the request according to the client.
Now it is fixed and working fine.
Thanks again.
Regards,
Gopinath.
|
|
|
|
|
I am getting this error:Severity Code Description Project File Line Suppression State
Error Invalid Resx file. Could not load type System.Collections.Generic.List`1[[Spring_2018_New_List_View_Macro_Box_Tester.LineItemData, Spring 2018 New List View Macro Box Tester, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 which is used in the .RESX file. Ensure that the necessary references have been added to your project. Line 133, position 5. Spring 2018 New List View Macro Box Tester C:\Users\\Desktop\C prog\Spring 2018 New List View Macro Box Tester - Copy (4) - Copy\Spring 2018 New List View Macro Box Tester\Form1.resx 133
This is the resx file. Can anybody tell me what is wrong?
Note: I only get this error after I do anything with the form that the custom user control is on.
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="mbListView1.LineList" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD/////AQAAAAAAAAAMAgAAALABU3ByaW5nIDIwMTggTmV3IExpc3QgVmlldyBNYWNybyBCb3gg
VGVzdGVyLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVs
bF1dLCBtc2NvcmxpYiwgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRv
a2VuPWI3N2E1YzU2MTkzNGUwODkMAwAAAGFTcHJpbmcgMjAxOCBOZXcgTGlzdCBWaWV3IE1hY3JvIEJv
eCBUZXN0ZXIsIFZlcnNpb249MS4wLjAuMCwgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1u
dWxsBQEAAABaU3lzdGVtLkNvbGxlY3Rpb25zLkdlbmVyaWMuTGlzdGAxW1tTcHJpbmdfMjAxOF9OZXdf
TGlzdF9WaWV3X01hY3JvX0JveF9UZXN0ZXIuTGluZUl0ZW1EYXRhAwAAAAZfaXRlbXMFX3NpemUIX3Zl
cnNpb24EAAA5U3ByaW5nXzIwMThfTmV3X0xpc3RfVmlld19NYWNyb19Cb3hfVGVzdGVyLkxpbmVJdGVt
RGF0YVtdAwAAAAgIAgAAAAkEAAAAAAAAAAAAAAAHBAAAAAABAAAAAAAAAAQ3U3ByaW5nXzIwMThfTmV3
X0xpc3RfVmlld19NYWNyb19Cb3hfVGVzdGVyLkxpbmVJdGVtRGF0YQMAAAAL
</value>
</data>
</root>
|
|
|
|
|
Your project is "confused"; you need to clean it up ... literally.
C:\Users\Desktop\C prog\Spring 2018 New List View Macro Box Tester - Copy (4) - Copy\Spring 2018 New List View Macro Box Tester\Form1.resx 133
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I had been working on a program for quite some time. For some reason, though the code was running, the design mode got screwed up. There are several errors.
1. One of my custom controls no longer seems to have design mode available at all. It now just looks like C# code and not a custom control and when I double-click on it in the solution explorer no design mode comes up.
2. Another user control (that makes use of the previous control mentioned) cannot be changed on the main form at all. When I try to edit or even delete it I get this error:
"An error occurred while processing this command: Type 'Spring_2018_New_List_View_Macro_Box_Tester.lineItemData' in Assembly 'Spring 2018 New List View Macro Box Tester, Version 1.0.0.0, Culture = neutral, PublicKeyToken=Null' is not marked as serializable."
And under output I get "The program '[16676] Spring 2018 New List View Macro Box Tester.exe: Program Trace' has exited with code 0 (0x0).
The program '[16676] Spring 2018 New List View Macro Box Tester.exe' has exited with code 0 (0x0).
Thanks,
FC
|
|
|
|
|
The "project properties" of a file can get fouled; causing the "Designer" to have issues.
Sometimes you can just "add" the "item" back as an existing item.
Sometimes you have to create a "new" control and paste your existing code back in.
I've had 3rd party projects that refused to honor my "text formatting rules" until I "rebuilt" some files.
A project file "fix" may help; but can also make the entire project (file) unusable if done wrong.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
I need help creating a class file that randomly generates a number of 10 characters, 0-9, A-Z. By generating a PIN it will create an authorization workflow to allow the user to authenticate the app. This number will be directed to a config file instead of a URL. The user goes thru a auth process and instead of calling back a URL there will be a page to randonly generate a pin. The randomly generated PIN will be stored in a database table.
For the database columns would get set properties be the best approach for each column in that table? Would this be the best approach for REST API? I am not very familiar with API's. Something like this
public class AuthorizationPIN
{
public int Id { get; set; }
public string AccessCode { get; set; }
public string PIN { get; set; }
}
|
|
|
|
|
You show one small component (of a larger process) and ask for "opinions".
At this point, it is neither right nor wrong.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Another smarmy smartass. Wow you are you f***ing dumb. I don't have any other code besides what I posted. I don't know where to begin with code to generate a PIN number that's why I asked!
F*** off a**hole seriously. I don't want to hear it from the moderators. There is no excuse for responding to me the way this guy responded to me. None!
|
|
|
|
|
|
And with a response like that you are hoping for support from a bunch of volunteers. If you don't like the response he gives you then ignore him as you will probably be ignored in the future.
Never underestimate the power of human stupidity
RAH
|
|
|
|