|
yes you are right, and thank you for the comment
but in the child class property is not displayed and here is the code used:
namespace CarteGrise
{
public class CarteGrise :ClassS
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClasseSup
#region variable et propriete
..................
#endregion
public List<ClassS> liste = new List<ClassS>();
|
|
|
|
|
If I understand this, then CarteGrise does not need to derive from ClassS at all. Also, if ClassS only contains one property then a class is overkill and unnecessary. A simple collection of stings would be sufficient.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: collection of stings
Ouch!
|
|
|
|
|
You may want to make the property virtual and override it in the child class.
|
|
|
|
|
|
|
Unfortunately not, but I work on now, if you have an A proposition, it will be appreciated.
think you
|
|
|
|
|
membre123 wrote: I work on now
Oookay... let us know how it goes.
|
|
|
|
|
Can you throw some more light on your problem ?
So that it is more clearer to understand and solve.....
Just give example of your derived class and what is lacking (your question)
so that it is clearly answered...
Jinal Desai - LIVE
|
|
|
|
|
|
Try to avoid Application.DoEvents... It's the wrong way to do things in .NET.
What you want is a BackgroundWorker. That's designed specifically for this situation. It goes something like this...
1) Create a BackgroundWorker for the "BusyOperation"
2) Create your progress dialog, and pass the worker to it, either in the constructor or via a property
3) The dialog hooks the RunWorkerCompleted event of the worker (Triggers when it's done), and optionally the progress changed event (See the MSDN documentation)
4) The dialog runs the background worker (Do not sit in a loop - Just exit the method). "BusyOperation" will automatically start asynchronously in a background thread.
5) When the RunWorkerCompleted event triggers, the dialog closes and returns control to the main form.
|
|
|
|
|
Hi Ian,
Thanks for your great advice.
I tried BackGroundWorker component also. However, I am getting same result - Form2 get hanged. Thereafter, I tried some stupid stuff and it worked.
I only copied form2_load code in public method (BuzyOperation) and called BuzyOperation() replacing it with frm2.show()
Form2 frm2;
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
frm2 = new Form2();
frm2.BuzyOperation();
}
After completing BuzyOperation(), below code will execute which will only show form2 with Job Done msg.
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
frm2.Show();
MessageBox.Show("Job done!");
}
I found the result as success, Now form2 is not getting hanged . I don't know what is going inside frm2.Show() (in our earlier scenerio), but i would like to know from you.
Pls. let me know.
Thanks in advance,
Chintan.
|
|
|
|
|
You're a little confused here... Don't worry, the threading is a little hard at first. There are two things to consider here...
1) The GUI thread has to stay unblocked, or your progress bar won't update
2) All controls HAVE to be created on the GUI thread, and only modified on that thread (Otherwise you get those crashes).
You're having problems because you're accessing the form inside the background worker... Can't do that. The point of the worker is that it works completely independently of the GUI, just letting you know when to update the progress.
So try creating the background worker from inside the Form2 constructor, then just call Form2's ShowDialog() from the main form.
public Form2()
{
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += BusyOperation;
bw.RunWorkerAsync();
}
Or something like that.
|
|
|
|
|
Check out this tip/trick:
http://www.codeproject.com/Tips/53695/Multiple-Subsequent-Main-Forms-in-Csharp-Apps.aspx[^]
I think it will help you do what you want to do.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hi everyone, I am having problem with serialPort getting data. When I send data to the device the device gets it but I should get some data back, but in reality I don't get any data whatsoever. I have a serialPort SerialDataReceivedEventHandler but it does not get fire. I don't know why.
if any help please let me know. I have been trying it for few days almost.
serialPort1 = new SerialPort("COM3", 19200, Parity.None, 8, StopBits.One);<br />
serialPort1.ReadTimeout = 1000;<br />
serialPort1.Handshake = Handshake.None;<br />
serialPort1.ReceivedBytesThreshold = 1;<br />
if (serialPort1.IsOpen)<br />
serialPort1.Close();<br />
serialPort1.Open();<br />
byte[] request1 = new byte[] {(byte)'P', 4, 19, 6, (byte)'@'};<br />
serialPort1.Write(request1, 0, request1.Length);<br />
serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived); <br />
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)<br />
{<br />
this.Invoke(new EventHandler(DoUpdate));<br />
}<br />
private void DoUpdate(object s, EventArgs e)<br />
{<br />
while (serialPort1.BytesToRead > 0)<br />
{<br />
textBox1.Text = serialPort1.BytesToRead.ToString();<br />
}<br />
}
|
|
|
|
|
There are loads of possibilities, but the first thing I would do it move the event hook to before the SerialPort.Write so that i fthe response is quick enough, you don't miss it. I don;t think that will solve your problem, but it is a good idea anyway.
Now, open a terminal program of some kind, select COM3 and manually enter your data. Does the device respond, and can you read the data on the terminal? If not, check your wiring - RX and TX data, RTS, CTS, DTR, etc - whatever the device might need. This is assuming the device is actually connected to COM3 at all...
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Hello OriginalGriff, I check all of these and it works.
|
|
|
|
|
If all of that saya you are getting responses, then what kind of data are you expecting? Could it be that all you need to do is add a single '+' character to your code?
textBox1.Text += serialPort1.BytesToRead.ToString();
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Hi everyone, I got my solution by doing this. If anyone has the same problem you may try this.
serialPort1 = new SerialPort("COM3", 19200, Parity.None, 8, StopBits.One);<br />
serialPort1.ReadTimeout = 1000;<br />
serialPort1.Handshake = Handshake.None;<br />
serialPort1.ReceivedBytesThreshold = 1;<br />
this.serialPort1.DtrEnable = true;<br />
this.serialPort1.Handshake = System.IO.Ports.Handshake.RequestToSend;<br />
this.serialPort1.ParityReplace = (System.Byte)(0);<br />
<br />
if (!serialPort1.IsOpen)<br />
serialPort1.Open();<br />
this.serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived);<br />
byte[] request1 = new byte[] { (byte)'P', 4, 40, (byte)'@' };<br />
serialPort1.Write(request1, 0, request1.Length);<br />
textBox1.Text = serialPort1.BytesToRead.ToString();<br />
this.serialPort1.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort1_ErrorReceived);
|
|
|
|
|
Hi,
please use PRE tags or the "code block" widget (not CODE tags or the "inline code" widget) to show multi-line code; it would preserve formatting, which makes things much more readable.
You can't touch your GUI Controls inside a DataReceived handler; this handler is asynchronous and runs on a ThreadPool thread, not on the main thread, so touching Controls there is forbidden. This[^] tells you more about it.
|
|
|
|
|
I want to create a datagrid inside a property grid,
As follows:
1. Property Name is same and it will have multiple dynamic rows. Each row will have 2 buttons. One to delete & one to fill data.
In datagrid it will be 3 columns, one for value & 2 for buttons.
Is it possible to create such a datagrid inside a property grid?
|
|
|
|
|
Sangeetha23 wrote: Is it possible to create such a datagrid inside a property grid?
Have you considered a UI Type Editor[^]? Or did you want to "embed" this datagrid into the PropertyGrid itself?
I are Troll
|
|
|
|
|
I gave him the same answer in Q&A. Hope he's got the message.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
It would be more fun when someone posted something creative
Would the question already be on SO or MSDN by now?
I are Troll
|
|
|
|
|
Thanks for your reply.
From msdn, i found UITypeEditor provides dropdwon & Modal buttons as uitypeeditoreditstyles. But I was not able to find the way to use both together.
Also the way to add rows dynamically is not clear.
|
|
|
|