|
Hi,
I have a Socket Class which connects, accepts the multiple clients and receive data from each client. I'm using a thread to accept the connection. I have to pass the IpAddresses and status to the GUI for display. How do I pass the value from thread to GUI? How do I user SendMessage/PostMessage method? Can I use the Invoke method. Please explain.
Thanks in advance
|
|
|
|
|
Cross thread GUI updation is not allowed. You need to use the invoke method.
|
|
|
|
|
Can you show me a sample code how to use Invoke method ?
|
|
|
|
|
string newText = ...;
form.Invoke(new MethodInvoker(delegate {
textBox.Text = newText;
}));
|
|
|
|
|
The code should be put in the thread or in the form?
|
|
|
|
|
Susanmat wrote: The code should be put in the thread or in the form?
It should be in the method which updates GUI. See the following sample
void WorkerMethod() {
if(this.InvokeRequired)
this.Invoke(new MethodInvoker(UpdateGUI));
}
void UpdateGUI() {
}
|
|
|
|
|
You might want to take a look at BackgroundWorker object. An example might look like the following, depending on your needs.
_bw = new BackgroundWorker();
_bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Worker_RunWorkerCompleted);
_bw.ProgressChanged += new ProgressChangedEventHandler(Worker_ProgressChanged);
_bw.DoWork += new DoWorkEventHandler(Worker_DoWork);
_bw.WorkerReportsProgress = true;
_bw.WorkerSupportsCancellation = true;
Look at
_bw.ReportProgress(..) method
|
|
|
|
|
The problem is My thread which updates the value is in a different class and I need to update the value in another from. The thread will accept clients and I need to update the status ( ture or false ) in the main form.So where should I call the delegate. I'm not able to get that. Please help
|
|
|
|
|
Hi,
My new project is to go through a list of tasks against each sql server 2005 machines. Each task has a different sql query which gets executed and the data is returned for each task.
I am thinking of having each task with the relevant sql inside an xml file.
i.e.
<tasks>
<task>
<name>get the version of sql server</name>
<sql>sql code here</sql>
</task>
<task>
<name>get domain name</name>
<sql>sql code here</sql>
</task>
<task>
...
</task>
</tasks>
Then a winform application goes through this list in the xml file and for each task it's sql gets executed against the master database.
1)
Is what I am doing correct?
2)
Can the .net front end pickup the sql as a string and execute it against the sql server 2005?
Thanks
|
|
|
|
|
arkiboys wrote: 1)
Is what I am doing correct?
Its one way of doing it.
arkiboys wrote: 2)
Can the .net front end pickup the sql as a string and execute it against the sql server 2005?
Yes, use the SQLCOMMAND object
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hello Friends,
I am developing an windows application in which i need to connect to MySQL Server through my application mean user enter the User Name and Password after that in a list box all the database of MySQL comes in Listbox.
So my problem is how to connect to MySQL database through my application
Please help me i am new in database..
Thanks
|
|
|
|
|
|
You can use ADO.NET[^] to create a connection to the database and then query all databases using a SqlCommand. To connect to the database you need a valid connection string[^].
I'd recomment to use the MySQL .NET connector[^] to use for this task.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Sir as you give me the link of connection string that is used to connect to MySQL server that's great but as i want to connect to like this user will enter Server Name, UserID and Password in the available textboxes and after that it will click on connect button that it should connect with all the available databases and shows them in Listbox
Thanks
|
|
|
|
|
I'm not sure if you can connect to the server without specifying a valid database. Maybe you should once connect to a database and then issue the SHOW DATABASES SQL command to get a list of the databases available to use for the next DB login from the listbox.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
$user="UsernameForYourMySqlDB";
$pass="PasswordForYourMySqlDB";
$db="YourDB_Name";
$link=mysql_connect("localhost",$user,$pass);
if(!$link)
die("Couldnt connect to MySQL");
mysql_select_db($db,$link) or die ("couldnt open $db: ".mysql_error());
print "connected to $db";
CheeN
|
|
|
|
|
How can I rename a file? what i am doing is copying a file from it's source to a certain directory. Now I want to rename the file name in the destination folder. How can I do that?
Thanking in advance.
|
|
|
|
|
|
I've done some looking around and I'm a bit confused
Here is an example of the data that's in the binding source
[IMG]http://i38.tinypic.com/xfoimp.png[/IMG]
what i want to do is sort on the 3rd row ( 4 or 3) and then sort by the date ( to see if the record is before a certian time
my idea to do this was to
filter the BS
BS.count
then unfiltered the BS
The problem i keep running into is that i cant say that i want Just 4 or Just 3
What I've come up with so far is
private int deadlineCount(DateTime Time, int LeagueID)
{
int total = 0;
string league;
if (LeagueID == 99)
{
league = "";
}
else
{
league = LeagueID.ToString();
}
BS.Filter = string.Format("LeagueID >= '{0}' and LeagueID <= '{0}'and [End] <#12/30/1899 {1}#", league, Time.ToString("h:mm tt"));
total = BS.Count;
BS.Filter = "";
return total;
}
But i keep running into problems that i cant use any operator ( like ,> ,= ,>=,) becuase it can not preform X onn system.int32 and system.string.
I've been looking around but all the example seem to be for strings or dates.
|
|
|
|
|
hi, i have a timer which call this method CalPrice().
The calprice will check the dategridview first column if the checkbox ==true, then calculate the price base on the the other column
private void CalPrice()
{
double price = 0.0;
foreach (DataGridViewRow dgw in dataGridProduct.Rows)
{
DataGridViewCheckBoxCell datacell = dgw.Cells[0] as DataGridViewCheckBoxCell;
try
{
if ((bool)datacell.Value == true)
{
price += Convert.ToDouble(dgw.Cells[6].Value.ToString());
}
lblTotalPrice.Text = "Total Price : $ " + price;
}
catch (Exception exc)
{
}
}
private void timer1_Tick(object sender, EventArgs e)
{
CalPrice();
}
}
I have set the timer to enable and interval to 1000(1 second). But when i load the form, the timer dont seems to start. It does not call the calPrice method
|
|
|
|
|
Hi!
Did you debug or are you just assuming that CalPrice is not being called?
If you're simply swallowing any exception that's being thrown, you can come to false conclusions.
Apart from that you either didn't assign an event handler for Tick or you didn't start the timer - not much else that can go wrong. Timers work just fine for a lot of people out there, you know...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
which event should i use to check if the column is tick or untick in a datagrid.
i tried cell_click but after i tick a checkbox, i have to click OUt of the datagrid, then it will populate the price
|
|
|
|
|
Maybe grid's CellValueChanged event - in the event arguments you get the index of the edited row and column index as well..
it's called when the value is commited ex. when the editmode is set to 'doubleclick or f2' [entar] commits value change.
also when you use Convert.To... you don't have to use ToString() on the converted object.
life is study!!!
|
|
|
|
|
I want to know how to create a simple program that can print data using PRINTER CLASSES(if any) of C#?..
|
|
|
|
|
I am not clear about ‘Printer Classes’, however printing can be done using PrintDocument and Print Preview control.
In case if you need to access printer settings you may do so by accessing System.Drawing.Printing.PrinterSettings class items.
-Dave.
------------------------------------
http://www.componentone.com
------------------------------------
|
|
|
|