|
funny...i have the code in front of me and it isnt working...i'll see it got some teeny weeny hidden flaw. thanx anyways.
|
|
|
|
|
Is it the chkShow checkbox that triggers the event, then?
---
b { font-weight: normal; }
|
|
|
|
|
Hi
I have to do a program in c# windows application such that form employs with a textbox, Progress bar, label and abutton.
I have used system.threading.timer such that , when a time is given in the textbox, (say 02:30 PM),then the progress bar progress and at last after progress bar finishes, the label which is in the form should turn red colour at that specified time(ie, 02:30 PM)..
but, I had a doen a program to such extent that when a time is given in textbox(say 02:30 pm) then the progress bar progresses and finishes soon and the label turns into red colour. Burt not at the specified time(ie, 02:30 pm)..
here is ,my part of coding. Please help me to do the the thing.
private class ThreadRunner
{
private Form1 _form;
private int _delay;
private System.Threading.Timer _timer;
public ThreadRunner(Form1 mainForm,int delayInSeconds)
{
_form=mainForm;
_delay=delayInSeconds;
}
public void Go()
{
// Create a timer passing in a delegate to the TimerElapsedmethod
// null is to be passed as a parameter to Timerelapsed
//0-start immediately
//10--cal a callback everysecond
_timer=new System.Threading.Timer(new TimerCallback (this.TimerElapsed),null,1000,1000);
while (_timer!=null)
Thread.Sleep(0); // Do nothing until timer has stopped
}
public void TimerElapsed(object o)
{
_delay--;
_form.Invoke(new MethodInvoker(_form.UpdateProgress));
if (_delay<=0)
{
_form.Invoke(new MethodInvoker(_form.UpdateLabel));
_timer.Dispose();
_timer=null;
}
}
}
//then inside teh button click
private void button1_Click(object sender, System.EventArgs e)
{
DateTime current = System.DateTime.Now;
DateTime end = DateTime.Parse(textBox1.Text);
TimeSpan ts = end.Subtract(current);
//value entered in the textbox
int timeToRun= System.Convert.ToInt32(ts.Seconds);
//set the maximum range of value
progressBar1.Maximum=timeToRun;
progressBar1.Step=1;
ThreadRunner tr=new ThreadRunner(this,timeToRun);
Thread t=new Thread(new ThreadStart(tr.Go));
t.Start();
}
this is the coding part which i had done.please explain and tell me wher to change and finish it .
dhol
|
|
|
|
|
From what I can see, this line
dhol wrote:
//value entered in the textbox
int timeToRun= System.Convert.ToInt32(ts.Seconds);
is not providing the correct number of seconds.You will need to add the number of seconds for the hours, minutes and secounds.
//This should work for your needs.
int timeToRun = ((ts.Hours * 60) * 60) + (ts.Minutes * 60) + ts.Seconds;
|
|
|
|
|
I have a contextmenu that is called when you press a button. The contextmenu is associated with a single treeview. however, there are other treeviews on the form. When the user clicks on a different treeview and hits the button that calls the contextmenu for the previous treeview, it gives me an error. i expect this. Nevertheless, I need to fix it. How can I get the contextmenu to show only when the user has selected the designated treeview? Thanks.
D
|
|
|
|
|
Hi There,
I have a C# windows application, that detects system device configuration details, using WMI.
My requirement is to get the Primary Display Driver information, when there are multiple display cards installed on a system.
Can some one help me? Thanks in advance.
Pkonaje
|
|
|
|
|
hi to all,
i am trying to create a balloon for my notifyicon, i have gleaned this from CP tutorial but i can get it going, can anyone help please ?
<br />
private void SMSEventLog_EntryWritten(object sender, EntryWrittenEventArgs e)<br />
{ <br />
ShowNotifyBalloon(NotifyFlags.Info, "SMS Event Monitor", "some sample text", NotifyInfoFlags.Error);<br />
}<br />
<br />
<br />
private enum NotifyFlags {Message=0x01, Icon=0x02, Tip=0x04, Info=0x10, State=0x08}<br />
private enum NotifyInfoFlags {Error=0x03, Info=0x01, None=0x00, Warning=0x02}<br />
private enum NotifyCommand {Add=0x00, Delete=0x02, Modify=0x01}<br />
private enum NotifyState {Hidden=0x01}<br />
<br />
[StructLayout(LayoutKind.Sequential)] <br />
private struct NotifyIconData<br />
{<br />
public System.UInt32 cbSize;
public System.IntPtr hWnd;
public System.UInt32 uID;
public NotifyFlags uFlags;
public System.UInt32 uCallbackMessage;
public System.IntPtr hIcon;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=128)]<br />
public System.String szTip;
public NotifyState dwState;
public NotifyState dwStateMask;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=256)]<br />
public System.String szInfo;
public System.Int32 dwTimeoutOrVersion;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=64)]<br />
public System.String szInfoTitle;
public NotifyInfoFlags dwInfoFlags;
}<br />
<br />
[DllImport("shell32.Dll")]<br />
private static extern System.Int32 Shell_NotifyIcon(NotifyCommand cmd, ref NotifyIconData data);<br />
<br />
private uint m_id = 0;<br />
<br />
private void ShowNotifyBalloon(NotifyFlags flags, string title, string text, NotifyInfoFlags infoFlags)<br />
{<br />
NotifyIconData data = new NotifyIconData();<br />
<br />
data.cbSize = (uint)Marshal.SizeOf(data); <br />
data.uID = m_id; <br />
data.uFlags = flags;<br />
data.szInfoTitle = title;<br />
data.szInfo = text;<br />
data.dwInfoFlags = infoFlags;<br />
<br />
Shell_NotifyIcon(NotifyCommand.Modify, ref data);<br />
}<br />
it doesnt show the balloon
kind regards,
g00fy
|
|
|
|
|
|
hi i want to implement incremental search in my windows application. it is not like how google does ( when you type 's' it displays all names starts with 's', this is how google works).
i am giving an example
suppose, there exist two parameters like this
'Investments in liquid mutual fund units'
'Redemption of liquid mutual fund units'
when user types "liquid" in textbox or combobox or any thing, it should display both parameters as drop down. That means it should work not only from starting letter but also any where from the middle.
can u please tell me techniques to do this? or suggest me any third party components that does this.
Thanks in advance
Satish
satish
|
|
|
|
|
how to delete a databse after creating it and creating a table inside it throgh the front end program with C# asp.net with ms sql.
ALL through the front end only.
tried with a stored procedure but drop databse is not allowed
|
|
|
|
|
The SQL documentation doesn't mention anything about not being able to DROP DATABASE via a stored procedure. Do you have enough permission to drop a database? You need to be logged in as a a user with sysadmin or dbcreator privileges.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucious
|
|
|
|
|
i want to load the foll ruleml into dataset but it dosen't allow it
plz suggest some solution .
the ruleml is as follows
- <root>
- <config>
- <engine-cfg>
- <logging>
<directory>/root/
<size>500000
<level>Debug 1
- <monitor>
<port>4455
<debug-mode>on
- <event-inputs>
- <event-input name="None" type="xmlrpc">
<port>4600
- <rules>
- <rule name="rule1" delivery="all" limit="None" create="single" parameter="append">
<description>
<event-ref enabled="yes">sit1
<condition-ref enabled="no">
<action-ref enabled="no">
<instance-limit>
- <rule name="rule2" delivery="all" limit="None" create="single" parameter="append">
<description>
<event-ref enabled="yes">sit1
<condition-ref enabled="no">
<action-ref enabled="yes">action1
<instance-limit>
- <event-defs>
- <event-def name="e1" type="basic">
- <parameters>
<parameter name="event_a" type="string">
<parameter name="host_name" type="string">
- <event-def name="e2" type="basic">
- <parameters>
<parameter name="service_name" type="string">
<parameter name="host_name" type="string">
<parameter name="price" type="number">
- <event-def name="e3" type="basic">
- <parameters>
<parameter name="eve_3" type="string">
- <event-def name="e4" type="basic">
- <parameters>
<parameter name="e4_param" type="number">
- <event-def name="sit1" type="composite">
<detect-event>e3
<no-detect-event>
- <event-selector name="">
<condition>con1
<scope>global
- <events>
<event-ref type="type">e1
<event-ref type="type">e2
- <detector>
- <sequence>
<event-ref name="order">e1
<event-ref name="sales">e2
- <event-def name="sit2" type="composite">
<detect-event>e3
<no-detect-event>
- <event-selector name="">
<condition>
<scope>global
<events>
- <detector>
- <and>
<event-ref name="sdfsd">e1
<event-ref name="event_2">e2
- <condition-defs>
- <condition-def always-true="no" composite="no" name="con1">
- <parameters>
- <parameter name="param1">
<event-ref type="type">e1
<param-ref>event_a
<instance>last
<function>
<key>no
- <expressions>
- <expression name="cond_one">
- <lhs>
<param-ref>param1
<operator>equal
- <rhs>
<value>1
- <composite-condition>
<not>
<condition-ref>cond_one
- <action-defs>
- <action-def name="action1">
<action-item type="script" name="act1">/root/helllo.sh
<action-def name="action2">
- <global-filter-defs>
- <global-filter name="filter1">
<in-event>e1
<out-event>e1
<condition-ref>con1
- <mappings>
-
event_a
<destination>host_name
|
|
|
|
|
You might want to repost this question, but check the "Do not treat <'s as HTML tags" checkbox before you click Submit.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What .NET class can I use to query the user rights of the user currently logged in?
|
|
|
|
|
Can anyone please explain the difference between these ?
|
|
|
|
|
The dataset keep changes in memory from the last time you call acceptchanges() method. If you call update(), then it will generate the corresponding sql command to write those changes back to the source database. If you call the acceptchanges() method, it will clear up the buffer without interacting with the source database.
Asura
|
|
|
|
|
AcceptChanges only updates your rows in the (in memory) dataset, that is - marks them as "not needed for actual database update". If you want to update your rows to the database, call your tableadapter's Update method. This method will call AcceptChanges on your rows if the rows get successfully updated to the database. The point here is, you should only call AcceptChanges on your rows, if you don't want them to be sent to your database to update records.
|
|
|
|
|
Hi,
I have problem when using transaction in .NET.
I use SqlTransaction object. I am also using dialup connection
to connect to my server. On server I have database install in MSDE.
In code below I have to save some parent-child data.
this.cn.Open();
if( this.cn.State == ConnectionState.Open )
{
tx = this.cn.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);
this.daParent.InsertCommand.Transaction = tx;
this.daDetail.InsertCommand.Transaction = tx;
this.daParent.Update(ds);
this.daDetail.Update(ds);
// DialUp connection break here
tx.Commit();
bOK = true;
}
}
catch(Exception exp)
{
bOK = false;
try
{
tx.Rollback();
}
catch (Exception ex)
{
MessageBox.Show("An exception of type " + ex.GetType() + ex.Message +
" was encountered while attempting to roll back the transaction.");
}
strError = "The following exception occured: " + exp.Message;
MessageBox.Show(strError);
}
finally
{
if( this.cn.State == ConnectionState.Open )
this.cn.Close();
}
As you can see I use Read uncommitted isolation level.
If my dialup connection break before tx.Commit command my Parent and child table will be locked.
When I start SQL Enterprise manager I can not see data in that tables.
The error code is 1222 (Lock request time-out period exceeded.)
So, if I start program on the other machine and try to look data in that tables I can't
see them because my tables are still locked.
Does anyone have any sugesstion how to solve this problem.
Thanks
Mikica
|
|
|
|
|
Put the transaction handling in a stored procedure instead.
---
b { font-weight: normal; }
|
|
|
|
|
Guffa,
I'm calling two store procedure!
|
|
|
|
|
Make one that does the work instead, so that the transaction doesn't have to leave the database server.
---
b { font-weight: normal; }
|
|
|
|
|
Class B includes a method "public void Save()".
Class A includes one field which type is B.
In some other class I am using reflection to gather information about class A and B:
<code>
{
Type ClassType = typeof(refl.A);
FieldInfo[] fields = ClassType.GetFields();
foreach(FieldInfo f in fields)
{
Type t = f.FieldType;
MemberInfo[] members = t.GetMembers();
foreach (MemberInfo m in members)
{
if (m.Name == "Save")
{
<big> ?????
</big>
}
}
}
}
</code>
When I find a function Save, i would like to call it. This isn`t a static method so I need to call it over some object. How to make it inside reflection?
----------------------------------------------------------------
The solution is:
public class B
{
public void Show()
{
System.Windows.Forms.MessageBox.Show( "B.Show called!" );
}
}
public class A
{
private B mB;
public B MemberB
{
get
{
return ( this.mB );
}
set
{
this.mB = value;
}
}
public A()
{
this.mB = new B();
}
}
public Class Tester
{
private A mA;
public void Do()
{
object lB;
lB = this.mA.GetType().GetProperty("MemberB").GetValue(this.mA, null );
lB.GetType().InvokeMember("Show",System.Reflection.BindingFlags.InvokeMethod, null, lB, new object[] { } );
}
}
How to make that without using properties at all?
|
|
|
|
|
What is it that you are trying to do, really? Why are you using reflection for this?
---
b { font-weight: normal; }
|
|
|
|
|
I am writing my own de/serialization and I need this to serialize object, that consist of other objects. Each of these objects will have a special function to serialize itself. I don`t want to make property to all fields, it`s a waste of time
|
|
|
|
|
I don't see any reason to use reflection to do this, if you have control over the objects yourself. There are loads of well behaving object oriented ways to handle it.
Why not make an interface containing a method for the object to serialize itself, and let the objects implement it. Each object would be responsible for calling it's own members to serialize them.
---
b { font-weight: normal; }
|
|
|
|