|
Hi,
best way would be to use BackgroundWorker instead of Thread . See here[^]
And a special hint for you: use Thread.Sleep (250ms might work) in event handler ProgressChanged to give processing time to the ui
Kind regards
|
|
|
|
|
If I understand you correctly, you need to update a Label with the status of the connection or the status of running a query? Correct?
You can try the following which I use to identify which files I am currently processing in a Thread.
First I declare a delgate for updating the Label.
public delegate void SetLabel(Control lblctrl, string filename);
Then I define the follwing to control the invoke.
private void setFilename(Control lblctrl, string filename)
{
if (this.WindowState == FormWindowState.Minimized)
return;
if (lblctrl.InvokeRequired)
lblctrl.BeginInvoke(new SetLabel(setFilename),
new object[] { lblctrl, filename });
else
lblctrl.Text = filename;
}
This allows me to call the fucntion from within any running thread. Like below:
foreach (string str2 in Directory.GetFiles(path))
{
setFilename(this.lblFileName, str2);
Hope this gives you some idea as to what I mean. You can do exactly the same for the progress bar.
Excellence is doing ordinary things extraordinarily well.
|
|
|
|
|
Hello just a simple question, can somebody tell what is the format of writing an if statement with these characters ":" or "?". i can across this once but don't know where.
Thanks
Back off i am coding
|
|
|
|
|
(statement?true:false)
Ex
int a=5;
int b=5;
MessageBox.Show(a==5?"a is equal to b":"a is not equal to b");
|
|
|
|
|
Thanks a lot
Back off i am coding
|
|
|
|
|
That is the ?: operator[^].
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Thanks a lot, and thanks for the example on the link
Back off i am coding
|
|
|
|
|
The technical name for this is the ternary operator (sometimes known as the conditional operator) if you ever need to look it up. Did you know that there are other cool operators available in C#? My favourite is the null coalescing operator or ?? . This works by chaining items together until a none-null condition is reached. For instance:
string value = GetValueFromDatabase() ?? GetValueFromConfigFile() ?? "None Selected"; In this example, if a null is returned from GetValueFromDatabase, the code will attempt to assign a value from GetValueFromConfigFile and if this returns null, None Selected is used (as it's the first none-null operator).
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Thanks a lot, now its working
Back off i am coding
|
|
|
|
|
Hi Every one,
now i m using window forms using C# , so my doubt is how can i bind datagridview to dataset . actually i finishes wrote code , but when i trace it ..data getting into datasource but its not displaying into datagridview ..let me Know is there any i can change into datagridview property . Please if u know scarp me.
Thanks
Raj
Some Thing need 2 do NEW
|
|
|
|
|
We cant know why? because we don't see the code.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Thanks for reply bro..
I need the answers bro..i thnik its not answer..
Some Thing need 2 do NEW
|
|
|
|
|
We cannot Help until we see the code where you bind the Grid
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Ok bro ..
this is my code once through it let me know where i did mistake.
SqlConnection cn = new SqlConnection("server=.;uid=sa;pwd=sa;database=Payroll1");
string ssql = "Select * from EmpDetails";
SqlDataAdapter da = new SqlDataAdapter(ssql, cn);
DataSet ds = new DataSet();
da.Fill(ds);
BindingSource bindgrd = new BindingSource();
bindgrd.DataSource = ds;
this.Datagridview1.DataSource = bindgrd;
Some Thing need 2 do NEW
|
|
|
|
|
Good Day Rajeshwar
I dont use Wizards to do my database.
can you do a Check for me. put your code in a try and check if there are any rows returned
SqlConnection cn = new SqlConnection("server=.;uid=sa;pwd=sa;database=Payroll1");
string ssql = "Select * from EmpDetails";
SqlDataAdapter da = new SqlDataAdapter(ssql, cn);
DataSet ds = new DataSet();
try
{
cn.open();
da.Fill(ds);
BindingSource bindgrd = new BindingSource();
bindgrd.DataSource = ds;
if(ds.Tables[0].Rows.count > 0)
{
this.Datagridview1.DataSource = bindgrd;
}
else
{
lblError.text = "No Rows Returned";
}
catch(SQlException ex)
{
lblError.text = ex.Message;
}
Finaly
{
cn.close();
}
Tell me if you get an Error or there are any Rows Returned. I wrote this here, so the logic is correct , just correct the syntax dont do copy and paste and tell me what it does.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
http://www.vuyiswamaseko.tiyaneProperties.co.za
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
Try this sample code
SqlCommand cmd = new SqlCommand();
cmd.Connection = sqlConnection();
cmd.CommandText ="your query";
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
datagridview1.DataSource = ds;
Regards,
Karthik K...
|
|
|
|
|
Hi,
I have created a Windows Form as "usercontrol" using vs.net 2003 with c#. In that Form I placed a Panel and below a horizontal scrollbar control. While I am trying to view the extreme right content of the Panel with the help of horizontal scroll bar the panel content is not viewable.(ie Panel content is not moving left- right)
And also I set "this.pnlWorkArea1.AutoScroll = true;" and its showing scrollbar but its not moving beyond the current viewable area.
Example: From the panel i am plotting graph with numbers 1 to 40 only its viewable up to 25.
Please advice me.
Thanks,
Palanivel
|
|
|
|
|
Hi,
I have a grid that displays multiple images (the grid can scroll horizontally and vertically)
At runtime I draw rectangles on each of the images which i intend to act as buttons.
I want to perform functions when when the user clicks on these drawn images.
How can I get the coordinates of the click event relative to the location of the cell? ie assuming the top left of each cell is 0,0
Thanks,
Chas
|
|
|
|
|
Found the answer:
it was the CellMouseClick event e.X and e.Y...
|
|
|
|
|
Hi,
How to erase a windows event log file programmatically.
Any idea..
Thanks
Md. Marufuzzaman
|
|
|
|
|
Assuming you have the relevant permisions, you can use EventLog.Delete to delete a particular log. Here's how I figured it out (who knows, this thought process may help you):
First of all, I thought to myself - this is an operation on the EventLog . Now, I know that there is an EventLog class, but if I hadn't known this the name would have seemed a logical place to start.
Then I thought - perhaps it has a DeleteLog entry.
I typed EventLog.DeleteLog into Google, and it suggested that it should actually be EventLog.Delete .
From there, I hopped over to the docs just to check that it was the item I thought it was - job done.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
You should buy a lottery ticket today
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi,
Whenever I tried to sort the mail item, it does not effect.
Microsoft.Office.Interop.Outlook.MAPIFolder mItem = TraverseTee(outlook.Session.Folders, "myfolder");
if(mItem!=null)
{
mItem.Items.Sort("Received", false);
int i=0;
foreach(Microsoft.Office.Interop.Outlook.MailItem item in mItem.Items)
{
listBox1.Items.Insert(i,item.Subject);
i++;
}
}
|
|
|
|
|
Hello,
I can't seem to find a solution that would allow me to connect through a chain of proxies using HttpWebRequest object. HttpWebRequest class does have a Proxy property but it only allows you to assign a single Proxy hop and this works as expected. What I need though is to create a connection throgh 3 proxy servers and I would like to know if this is possible with HttpWebRequest. If not I would like to know if there is any other way of doing this in .NET 3.5, maybe an open source library, or an example, anything that would help. If even this does not exist I would like to know if there are any open source 3rd party tools that would allow me to do this.
Thank you for your answers in advance
Yours sincerely,
Andrea
|
|
|
|
|
My application having two datagrids-->datagrid1 and datagrid2
datagrid1 is having ID,FileName,Comments columns
datagrid2 is having FileName column.
i wantt to drag and drop value from datagrid1 to datagrid2.
can anyone help me
|
|
|
|