|
Hi,
I think you might be better off deferring adding data to the listview until results arrive from the networked computers.
I'm guessing that your program already has code to handle one host name taken from the Host textbox, probably in the Search button click handler, and it should be possible to reuse that code. We refactor the code in the click handler like this:
private void SearchBtn_Click(object sender, EventArgs e) {
DoTask(HostTextBox.Text);
}
The DoTask method contains all the functionality to query and process the results from ONE networked machine. The advantage of refactoring is that you can now call the DoTask method for each host name in the list, code which could be placed into a menu click handler.
private void OpenFileMenuItem_Click(object sender, EventArgs e) {
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.Title = "Load machines to search";
fdlg.InitialDirectory = @"c:\";
fdlg.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
fdlg.FilterIndex = 2;
fdlg.RestoreDirectory = true;
if (fdlg.ShowDialog() == DialogResult.OK) {
string[] machineNames = System.IO.File.ReadAllLines(fdlg.FileName);
foreach (string hostname in machineNames) {
DoTask(hostname);
Application.DoEvents();
}
}
}
Now your program can handle a list of hosts, by reading a file, and it can still take a single name from the textbox.
The user interface (UI) can freeze during list processing because the loop prevents any UI updates until iteration has completed. The correct way to keep a UI active is to execute long duration tasks in a secondary thread, but to do that is another level of complexity which I don't think you're ready for just yet. I've inserted a call to Application.DoEvents() into the loop which is the poor man's way of keeping the UI responsive. In simple terms this allows keyboard or mouse input to be read, and the application windows to be redrawn on every iteration. Without it the UI would not update until the loop had ended.
Alan.
|
|
|
|
|
I'm trying to write a XmlDocument like so:
<br />
XmlDocument doc = new XmlDocument();<br />
<br />
<br />
StreamWriter s = new StreamWriter("output.xml");<br />
<br />
XmlTextWriter w = new XmlTextWriter(s);<br />
<br />
<br />
doc.WriteContentTo (w);<br />
<br />
w.Flush();<br />
<br />
s.Flush();<br />
s.WriteLine();<br />
s.Close();<br />
But it writes all the xml on one line. How do I make it put each node on its own line?
|
|
|
|
|
Could try the Formatting property of the XmlTextWriter.
|
|
|
|
|
|
|
Hi,
I've a list view which has got 5 columns some time i'll get fill only one column and 1 row, by that time remaining columns are highlighted with square (basically selected) I want to avoid that, any chance to restrict users to select or disable one particular row in list view?
|
|
|
|
|
can i call button_click event from code
pictureclick_event()
{
//from here i want to call button clcik event with out clicking button
}
buttonclick_event()
{
}
This code was posted by me...
|
|
|
|
|
Call the button's PerformClick() method
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
tnx
m doin device application in .net
how to close a form and navigate to another form
this.close and dispose is not working
This code was posted by me...
|
|
|
|
|
Vivek Vijayan wrote: how to close a form and navigate to another form
Hi,
This code should do it:
this.Hide();
Form NewForm = new NewForm();
NewForm.ShowDialog();
I hope this helps.
|
|
|
|
|
Technically, yes, because an event handler is just a function like any other.
But - it may be better in these cases to separate out the code that would be called by multiple event handlers into its own function. Something like this:
void MyCommonFunction()
{
...
}
void PictureClick_Event(o as object, e as EventArgs)
{
MyCommonFunction();
}
void ButtonClick_Event(o as object, e as EventArgs)
{
MyCommonFunction();
}
|
|
|
|
|
|
Hi,
I think I understand your question. What you're looking for is this:
pictureclick_event()
{
MySexyButton.PerformClick();
}
// The above code will perform a Click on the button without you having to actually click it. Pretty sweet huh?
I hope this helps.
If you liked the answer I have provided, then please click the 'Good Answer' link on the bottom-right of my post.
|
|
|
|
|
How to fill a dataset using two tables coz i want to use that dataset for crystal report.
|
|
|
|
|
DataTable table1 = new DataTable();
DataTable table2 = new DataTable();
DataSet dataSet = new DataSet();
dataSet.Tables.Add(table1);
dataSet.Tables.Add(table2);
|
|
|
|
|
the code is like this..
SqlCommand cmd;
SqlConnection conn;
SqlDataAdapter sda;
conn = new SqlConnection("server=Sai2; database=Inventory; uid=sa; pwd=123456;");
cmd = conn.CreateCommand();
cmd.CommandText = "select * from stock";
sda = new SqlDataAdapter();
sda.SelectCommand = cmd;
DataS.Stock ds = new SisInventorySystem.DataS.Stock();
sda.Fill(ds, "stock");
Crystal_Reports.TotalStockRpt TtlStkRpt = new SisInventorySystem.Crystal_Reports.TotalStockRpt();
TtlStkRpt.SetDataSource(ds);
crystalReportViewer1.ReportSource = TtlStkRpt;
crystalReportViewer1.DisplayToolbar = true;
Now i have to run one more Query "select * from Company" having nothing in common between table company and stock.
|
|
|
|
|
You can write a stored procedure that returns multiple recordset and get the resultset directly mapped with a dataset, it will create the same number of datatables in your dataset as the count of resultset in your procedure...
|
|
|
|
|
DataAdapter.Fill perhaps? If you're using SQL Server for your database, you can call a stored procedure that returns two result sets - each will be filled in the dataset as a separate DataTable. The stored procedure is simple:
CREATE PROCEDURE Sample
AS
BEGIN
select * from table1;
select * from table2;
END
|
|
|
|
|
ok...
and after what to write...
da.fill(ds,"whichtable");
can i write the both table....
|
|
|
|
|
Access the tables through the DataSet's Tables collection:
DataTable dt0 = ds.Tables[0];
DataTable dt1 = ds.Tables[1];
|
|
|
|
|
Done All the things but can not Solved ...
sda.fill(ds,"Table name Is Must.")
Is there any Solution...
|
|
|
|
|
Why is the table name a must upon filling? You can always change the table name (if you really need to) after filling the set like this:
sda.Fill(ds);
ds.Tables[0].TableName = "tableNameIsAMust.";
ds.Tables[1].TableName = "somethingElse";
Or is it that you are looking to execute two queries separately (instead of together in one batch)? In that case, you could supply separate table names upon filling:
da1.Fill(ds, "Table1");
da2.Fill(ds, "Table2");
I'm having difficulty understanding exactly why this is problematic for you. Can you explain?
|
|
|
|
|
Actually I have to make a crystal report which needs two table nothing is common in between these two tables.i tried all these suggestion in this section but not working...i already posted my code...
|
|
|
|
|
With SQL Server:
"SELECT * FROM Table1 ; SELECT * FROM Table2"
(Other database engines don't allow multiple statements in a command.)
|
|
|
|
|
closin a form in application hangs the application or closes the applcn
i m doin a mobile application how can i close the form in the middle of running when a condition is met
i want to navigate to another form when a condition is met
this.close() and this.dispose is not working.
if (str.Equals("stop"))
{
//form shud be closed and navigate to another form
}
This code was posted by me...
|
|
|
|