|
<b>Hello, </b>
I can't find best practice to my issue, I will appreciate any help from you:
In my scenario there is WinForm with few RadioButtons and Button. the user choose one of the RadioButton and then press on the Button.
When the user click there are two things:
1. Start thread for searching...
2. Create new TextBox for display the results from the thread I just started.
How can I "connect" the TextBox with the thread, so when I got the results from the thread I will know where to display the results ?
Please remember the user can click one after another on the Button and each click will open new TextBox, so each thread must display its results on "its" TextBox.
<b>Thanks in advance,
Moshet </b>
|
|
|
|
|
You could create a little class that represents one search job. It would hold a reference to the textbox, create its own thread, execute the necessary search in the background, and take care of displaying the results. You then would instantiate said class each time the user pushes the button.
Warning: you should create and manipulate Controls only with code running on the main thread. See this article[^].
|
|
|
|
|
Thank you Luc.
In my application I have 2 layers (I try to keep this way as possible as I can):
1.Bussiness Objects - the search engine (objects)
2.Presentation - forms.
Your suggestion will mix-up those layers.
As I know - in object oriented you should at least save those layers clear one from each other.
I will be glad to get your opinion about it.
Best Regards.
|
|
|
|
|
Moshe T wrote: Your suggestion will mix-up those layers
Huh? I agree with having those layers, however they need to exchange your information.
An ECG is an object (belonging to your "Business Objects"), even if you don't look at it; and it does not care how it gets viewed, so passing GUI stuff to it would be wrong.
A Form or a Control for viewing an ECG is a specialized object (part of your presentation layer), it needs to get ECG data, so either let it accept an ECG, or, maybe better, some interface that suffices for its purposes. In the latter case, the ECG object must provide that interface, and the coupling between both layers is more relaxed as the Form/Control doesn't require an actual ECG object any more.
Unless I'm mistaken, that is what I meant to say, and said earlier.
|
|
|
|
|
Well, your explanation is quite similar what I have here !
I thought there are best practice for this issue, or build-in solution in the .NET Framework.
(I was searching information about Binding data, but my scenario doesn't fit for that).
Thank you very much for your assistance
<b>Best Regards.</b>
|
|
|
|
|
BackgroundWorker.RunWorkerCompleted[^] should work for you.
The RunWorkerCompleted event will fire on the same thread the BackgroundWorker was started from (typically the main GUI thread). You'll need to get your search results from the DoWork event into the RunWorkerCompleted event, and you should have access to your TextBox.
Dybs
The shout of progress is not "Eureka!" it's "Strange... that's not what i expected". - peterchen
|
|
|
|
|
Hi
I hope you can help me
I'm trying to create my own control to support the following:
It should be a table/grid (row X cells) where each cell can contain a textfield/label/button/checkbox etc.
So I created my own Control extending the TableLayoutPanel and added a textfield for each cell in the constructor of my control.
When I add my own TableControl in my hosted Designer to my form then I'm only able to access the properties of the TableLayoutPanel. But I cannot select each Textfield in the cells in the TableLayoutPanel seperately to change those properties.
If I only add the TableLayoutPanel to my form and consequently add all the textfields to the cells, then I'm able to select those textfields seperately.
How can I implement those behaviour, when the tableLayoutPanel must not get created wit empty cells (every cell must contain a control and the control must be able to get selected to change the properties).
If there is a better choice than the TableLayoutPanel for my planned behaviour.
I hope you can understand my intention.
Thanks in advance
|
|
|
|
|
I believe that to achieve the results you want you will have to implement a custom designer for your new control.
This article may give you a start Designing Nested Controls[^]. At the very least it should give you some terms to search on (ParentControlDesigner for example).
If that does not lead you to a solution then you could 'surface' the properties of the internal controls (see snippet below). This will not allow them to be selected but will at least allow their properties to be set.
class MyPanel : TableLayoutPanel
{
public string NameText
{
get
{
return myNameTextBox.Text;
}
set
{
myNameTextBox.Text = value;
}
}
}
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.”
|
|
|
|
|
Thanks.
I'll have a closer look at it
|
|
|
|
|
Hi. I'm using an embed windows media player in a windows form in vb.net.
The Media Player has the uiMode = none. The Media Player Control has a fixede size of width = 480 and height =320
The videos plays fine, but when i pause a video(with a button of my form) the windows media player change its size without any reason. it happens sometimes when the video starts too. Does Anybody know why this is happening and how can i fix it?.
Please forgive my english. I need help. Any suggestions or article you know about this topic. thanks.
|
|
|
|
|
Hi,
I wrote 1 form and 1 component for my application
- parent form with listBox (which can display the incoming string)
- child component whic is a socket class to receive and send data.
In my program, i create a socket with child component. Then it will receive the incoming data with asynchronous method. When a string is received, i would like to pass it to the parent form, which has a function for string manipulation and display the string finally.
However, I don't know how to do the "child data pass to parent" method.
Do you have any idea for me?
Does Windows From have any API for that?
Thanks.
Ken
|
|
|
|
|
KenKen Wong wrote: Does Windows From have any API for that?
How about raising an event on the child form that the parent form listens to and acts on? All the child form needs to do then is check that there's something listening to the eventhandler and raise the event.
|
|
|
|
|
|
|
You're welcome. Glad to be of help.
|
|
|
|
|
Hi,
I have to print receipts on Thermal Printer. I found a example on net on http://www.taylorsnet.co.uk/Forums/ForumPosts.aspx?Subject=7[^]
But am wondering about the 1st parameter 'A = Text and H-Location (A for text, B for Barcode)
fileWriter.Write("A800, 20, 1, 3, 2, 2, N") ' 1st line
..........
fileWriter.Write("A750, 20, 1, 3, 2, 2, N") ' 2nd line
.........
A for Text is fine. but the H-Location is Y axis right - I assume as (B)V-location is same in both the line; so that should be X-axis.
If H-location is y, axis then why it is decreasing i.e from 800, 750 ..
Can anyone help me with this part. Is their anyway I can see the contents without printing - like saving the outFile or seeing in PrintPreview, etc.
Any help or guidance is highly appreciated.
Thanks & Regards,
|
|
|
|
|
You're using what looks like a File writer already. Just change whatever is being open to a file instead of whatever you're opening for the printer. Then you can send everything to a file instead of the printer.
|
|
|
|
|
Hi Dave,
By just changing to a file, it will give results like :
N
A800, 20, 1, 3, 2, 2, N"Name"
A750, 20, 1, 3, 2, 2, N"Address"
P1
I wanted a way to see the results like we see in Print Preview. Our print lines include g.drawString..., but the resuts are different. That's what I was asking for Thermal Printer. To know the code kindly refer the link provided in main msg from where I have taken.
Do you know anything about H-Location of this issue ?
Thanks & Regards,
|
|
|
|
|
The only way that's going to happen is if you write your own parser for the language the printer understands (implementing all the commands you have documentation for) and render the image in whatever window you want. There is no class in the .NET Framework that will do this for you. There is probably no 3rd party class that will do this either unless the printer you're using and the commands you send to it are one of the standard page description languages, like PostScript, PCL, ...
|
|
|
|
|
This code will only work if you're using a Zebra printer that understands these codes. It's not going to work for every thermal printer in existance.
Your best source of information on the code you send to the printer is the documentation on your printer, not someone elses code.
|
|
|
|
|
As much as i can remember you have a Zebra designer software comes with zebra printer driver CD. You can design your barcode using that software and also you can export that in a text format(ie the way you are printing).
also you have all documents (comes in a folder) how to print the barcode in that CD itself.
I think reading those documents will help you.
|
|
|
|
|
Hi,
In my desktop app developed in VB.NET, I want to send an email.
Private Sub CreateMessage()
Dim from As New MailAddress(fromTxt.Text.Trim, nameTxt.Text.Trim)
Dim toAdd As New MailAddress(toTxt.Text, totitle)
Dim msg As New MailMessage(from, toAdd)
msg.Subject = subjectTxt.Text.Trim
msg.Body = messageTxt.Text.Trim
Dim cc1 As New MailAddress(cc1.Text)
Dim cc2 As New MailAddress(cc2.Text)
msg.CC.Add(cc1)
msg.CC.Add(cc2)
Dim client As New SmtpClient()
Try
client.Send(msg)
ToolStripStatusLabel1.Text = "Message Sent Successfully"
Catch ex As Exception
ToolStripStatusLabel1.Text = "Error Sending Mail"
MessageBox.Show("Error sending mail : " & ex.ToString, "ERROR :: Try Again", MessageBoxButtons.OK, MessageBoxIcon.Error)
Finally
cc1 = Nothing
cc2 = Nothing
from = Nothing
toAdd = Nothing
msg = Nothing
client = Nothing
End Try
Return
End Sub
Above is the code I use to send email. I have imported System.Net.Mail & set MailMessage object properly also created SmtpClient. But I don't know what and how to set the Smtp host. I mean, the app will be on differnet PC's & all will be using different means of Internet access. Then how can I know and set the host before sending message. I tried adding "localhost" but that didn't worked. What to do and how to achieve the goal ?
This should be possible and in a simpler manner - when I can do the same in my Java apps then why not in .NET apps. Searched a lot on net also, but every example showed "<your server="" name="">", but how can I know the server name of each PC ???
Any help guidance is highly appreciated.
Thanks & Regards,
|
|
|
|
|
|
Oh Thanks Dave for this.
Just wanted to confirm a point and make myself understand properly.
So a mail will have From & To. From will be someone who is writing & To will be my mail address (I will receive it). If my mail address i.e. To is of hotmail, then I got to implement of Live Mail, if of Yahoo then of Yahoo & if of gmail then of gmail. Then regardless of what the From address belong. If To is "...@hotmail.com" & From is "...@xyz.com" ; If I implement of Live Mail, then I will receive all mails send from anyone.
Am I correct or wrong at any angle. Kindly let me know.
Thanks & Regards,
|
|
|
|
|
From Address is the person sending, To address is the receiver, in this case you.
The SMTP server needs to be any server for which the user who is sending the email is authorised to use. It doesn't matter who the target (TO) address is, it is dependant on who the sender is.
SMTP servers generally need to be authorised, as there are very few open relays now due to the abundance of spam and abuse they receive.
|
|
|
|