|
<br />
public void task()<br />
{<br />
Thread.Sleep(9000);<br />
}<br />
private void button_Click(object sender, System.EventArgs e)<br />
{<br />
this.progressBar1.Value=0;<br />
Thread t=new Thread(new ThreadStart(task));<br />
t.Start();<br />
while((t.ThreadState & (System.Threading.ThreadState.Stopped | System.Threading.ThreadState.Unstarted)) == 0)<br />
{<br />
if(this.progressBar1.Value==this.progressBar1.Maximum)<br />
{<br />
this.progressBar1.Value=this.progressBar1.Minimum;<br />
}<br />
this.progressBar1.PerformStep();<br />
Thread.Sleep(500);<br />
}<br />
t.Join();<br />
}<br />
works the first time, progressbar progresses nice and neat, never works again. what am i missing here?
|
|
|
|
|
You'd be better off encapsulating your ProcessBar code into it's own seperate control. Something that includes it's own Timer to increment itself. You could than use this control in whatever project you wanted and you wouldn't have to worry about coding some custom garbage like what you posted.
Take a look at this[^] article on MSDN for an example.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I don't know how it works the first time. You are blocking the UI thread by looping till the worker thread completes. So your calls to PerformStep won't really get through till button_Click completes, by which time you're already done.
I'd suggest that you update the progress bar from the worker thread (by using BeginInvoke/Invoke as this[^] article describes.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
i make a query on my database.
I want the image data inside a row.
I select it and i start to read data.
The problem is that sometimes there is no data inside, so if i try to read i get exception.
Can i check if there is data inside that field before start ot read?
That field doesn't support NULL default value.
i use Microsoft Access database .mdb and ADO.NET
|
|
|
|
|
If the field doesn't support NULL and it can be blank, then your only option is to check the length of the data in the field. Images are usually going to be more than 0 bytes long.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I want to rotate a control, take for example a button Control or a label control to some angle. But i dont know how to attain that..
i tried setting the region of the control with a graphics path whose transform set to rotate about its center...but im not able to get the output...
Can anybody help me?
Thanks,
Rajesh
|
|
|
|
|
Off the top of my head, you'll have to create your own version of the controls you want to visually rotate and supply the functionality for it.
There may be another way to do it by dropping the controls in some other container and rotating the container somehow, but i really can't see that happening.
Another option is a 3rd party Windows Forms Control library.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Right off the very tip top of my head....
Could you just decrement the X size/location and increment the Y size/location in a for loop (or do loop)? The text wouldn't rotate, but the control would appear too.
Just a thought.
Of course you have to mark your start position and reverse at 90 degrees, etc, etc...
www.lovethosetrains.com
|
|
|
|
|
No, it wouldn't. It would just make the button appear tall and narrow, not rotated to any angle. Re-read the original post...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actually i tried transforming the region of the control to a rotation...
for example,
Region reg = new Region();
Matrix matObj = new Matrix();
matObj.RotateAt(/*some angle*/, /*with respect to some point*/);
reg.Transform(matobj);
myControl.Region = reg;
Iam able to attain the rotation...but supposing the region (reg in this example)is in another shape(than rectangle)...say ellipse, then the shape of the ellipse is not visible completely....reason is that the rectangle coordinates(i.e. the original rectangle size) used to draw the ellipse is smaller than the rotated structure...(after rotation, the location of points are actually out of the bounds of the controls client rectangle...)
So i tried to get the size of the outer rectangle which has completely both the original and the rotated rectangles... by some trignometry...
but nope, im not getting the exact coordinates...
can you help me in this??
I
Thanks and Regards,
Rajesh
|
|
|
|
|
Hi!
What is the best way to retain a value between sessions. For example, if you have a login dialog and the user account name is likely to be the same the next time the application starts, what is the preferred way to fill the textbox with user account name from the previous time?
Thank you
|
|
|
|
|
You can either store it in the Registry, probably under the CurrentUser key, or in a file somewhere.
But, keep in mind, this is considered a mild security risk. You might also want to include an option to turn this feature on/off.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I want the button handeller "btnOpen_Click" to open a spacefic folder has this path (D:\MyFolder) what can i do ?
thanks in advance .
misho
|
|
|
|
|
You can browse the documentation for OpenFileDialog[^] and use the InitialDirectory property.
mav
|
|
|
|
|
Hi,
Can someone please tell me where I can find a Step-by-Step guide to building a Forum Discussion Board?
Thanks!
Illegal Operation
WannaBe and GonnaBe Systems Developer
|
|
|
|
|
http://www.codeproject.com/asp/codeproject-forum.asp[^]
This is a description of the CP forums ,and also microsoft has released a free code for its community in a web site named communityserver but i really don't remember the URL if you googled it you will of course find it,and its in C# .
|
|
|
|
|
Hi,
i'm trying to develop a C# windows service that needs to expose procedures and functions that will be called remotely via an application that is going to be developed in delphi 6.
i'm totally new to distributed applications, so if anyone can give me some guidance as to how i can accomplish this, i will be VERY greatfull.
Thanks a million!
Afzal Hassen
|
|
|
|
|
hi all,
I want to write a C# Application to Uninstall Applications(Exes)?
Can any one guide me?
thanks in advance..
|
|
|
|
|
|
hi,
Yes..it is in the "add/Remove programs" in the Control Panel.But I want to uninstall it from Start-->Programs--->ABC-->uninstall ABC
Menues..
How do we get Uninstall Program for above Menue.?
Thanks in advance..
|
|
|
|
|
Hi!
You could simply call msiexec to uninstall your application:
msiexec /uninstall MySetup.msi
There are commandline parameters to make it a silent (un)install and several others.
You can find the documentation here: MSIEXEC docu on MSDN[^]
Regards,
mav
|
|
|
|
|
I am attemping to bind the data from an xml file into a datagridview. I have achieved this via the following code:
<br />
quotesDataSet.ReadXml(Properties.Settings.Default.XmlQuoteFile);<br />
<br />
quoteGrid.DataSource = quotesDataSet;<br />
quoteGrid.DataMember = "quote";<br />
This automatically binds the four elements of the quote parent into four rows. However, from that point on, I cannot rename the header rows or control them in any way. I've tried everything from attempting to assign a datagridtablestyle, to simply using quoteGrid.Columns[1].HeaderText = "Text"; Can anyone provide me with a working example of how to achieve this?
|
|
|
|
|
I think it makes sense that you can not change the header because you are directly linking the xml file to the datagrid. To change the header you need to create custom columns using DataGridTextBoxColumn classes (example follows). Another option you might have is to read the xml into a dataset and modify the table with your data so it has a different column name.
Example for custom table:
Instead of setting Datasource, use the following:
<br />
this.dataGrid1.SetDataBinding(myDataSet, "MyTable");<br />
CreateCustomTable();<br />
</code<br />
<br />
<code><br />
private void CreateCustomTable()<br />
{<br />
DataGridTableStyle ts1 = new DataGridTableStyle();<br />
ts1.MappingName = "Department"; <br />
ts1.AlternatingBackColor = Color.LightGray;<br />
<br />
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();<br />
TextCol.MappingName = "Name";<br />
TextCol.HeaderText = "Department Name";<br />
TextCol.Width = this.dataGrid1.Size.Width-60;<br />
ts1.GridColumnStyles.Add(TextCol);<br />
<br />
this.dataGrid1.TableStyles.Add(ts1);<br />
}<br />
<br />
|
|
|
|
|
I'm working with the new Visual C# Express beta and the latest of the .Net 2 version. Unfortunately, they have replaced datagrid with datagridview, and datagridtablestyle does not seem to have a new version. Unfortunately, they also have not provided any documentation that I can understand for achieving the same effects. Any other thoughts?
Thanks for the help either way.
|
|
|
|
|
In that case instead of quoteGrid.Columns[1].HeaderText
try yourDataGridView.Columns[1].Name="your column name" .
I hope that helps, I really haven't tried the new version yet.
|
|
|
|