|
Hi Nishant,
You can DataColum.Expression property for doing this. This allows you to calculate the values of a colum.
1) Create a new colum with a proper data type.
2) Set the expression property of that coloum . (Ex "rate * 0.8")
3) Add this colum to the table.
The new column is filled with the calculated value.
Hope this will help you.
Regards
SGS
|
|
|
|
|
Thanks a lot, it worked.
But one more thing can i have this column in some other table...
|
|
|
|
|
Hi people,
I have a running small windows forms application on 1.0 and 1.1, but when I use the code on 2.0 beta, it says that the thread cannot access an object that it hasn't created . Can anyone check this out for me please? I have 2 files, one called Main.cs, which is the main program and then I have Ticker.cs which is another window class called from Main. I will post below the whole code for both files, if anyone has any clue about that.
I am using SharpDevelop for 1.1 and Visual C# Express 2005 beta for 2.0
Main.cs
<br />
<br />
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using System.Threading;<br />
<br />
<br />
namespace Exercice1<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Label label1;<br />
private System.Windows.Forms.Label lblText;<br />
private System.Windows.Forms.Button btnClose;<br />
private System.Windows.Forms.Timer timer;<br />
private System.ComponentModel.IContainer components;<br />
private System.Windows.Forms.ProgressBar progressBar1;<br />
<br />
<br />
<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
<br />
this.components = new System.ComponentModel.Container();<br />
this.timer = new System.Windows.Forms.Timer(this.components);<br />
this.label1 = new System.Windows.Forms.Label();<br />
this.lblText = new System.Windows.Forms.Label();<br />
this.btnClose = new System.Windows.Forms.Button();<br />
this.progressBar1 = new System.Windows.Forms.ProgressBar();<br />
this.SuspendLayout();<br />
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.label1.Location = new System.Drawing.Point(16, 16);<br />
this.label1.Name = "label1";<br />
this.label1.Size = new System.Drawing.Size(264, 23);<br />
this.label1.TabIndex = 0;<br />
this.label1.Text = "Welcome";<br />
this.lblText.Location = new System.Drawing.Point(16, 56);<br />
this.lblText.Name = "lblText";<br />
this.lblText.Size = new System.Drawing.Size(264, 23);<br />
this.lblText.TabIndex = 1;<br />
this.lblText.Text = "Loading XYZ...";<br />
this.btnClose.Location = new System.Drawing.Point(208, 128);<br />
this.btnClose.Name = "btnClose";<br />
this.btnClose.TabIndex = 2;<br />
this.btnClose.Text = "Cancel";<br />
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);<br />
this.progressBar1.Location = new System.Drawing.Point(16, 96);<br />
this.progressBar1.Name = "progressBar1";<br />
this.progressBar1.Size = new System.Drawing.Size(264, 23);<br />
this.progressBar1.Step = 1;<br />
this.progressBar1.Minimum=0;<br />
this.progressBar1.Maximum=20;<br />
this.progressBar1.TabIndex = 3;<br />
this.timer.Enabled = true;<br />
this.timer.Interval = 300;<br />
this.timer.Tick += new System.EventHandler(this.timer_Tick);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.ClientSize = new System.Drawing.Size(294, 175);<br />
this.Controls.AddRange(new System.Windows.Forms.Control[] {<br />
this.progressBar1,<br />
this.btnClose,<br />
this.lblText,<br />
this.label1});<br />
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;<br />
this.Name = "SplashForm";<br />
this.Text = "Loading MyApp...";<br />
this.Load += new System.EventHandler(this.SpashForm_Load);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
private void btnClose_Click(object sender, System.EventArgs e)<br />
{<br />
this.DialogResult = DialogResult.Cancel;<br />
this.Close();<br />
}<br />
<br />
private void timer_Tick(object sender, System.EventArgs e)<br />
{<br />
if (progressBar1.Value != progressBar1.Maximum)<br />
{<br />
progressBar1.PerformStep();<br />
<br />
}<br />
else<br />
{<br />
this.timer.Tick -= new System.EventHandler(this.timer_Tick);<br />
Ticker t1 = new Ticker();<br />
t1.Show();<br />
this.Hide();<br />
}<br />
<br />
}<br />
<br />
private void SpashForm_Load(object sender, System.EventArgs e)<br />
{<br />
if (progressBar1.Value == progressBar1.Maximum)<br />
{<br />
<br />
}<br />
}<br />
protected override void OnClosing(CancelEventArgs e) <br />
{<br />
this.Dispose();<br />
Environment.Exit(0);<br />
<br />
}<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
}<br />
<br />
<br />
}<br />
<br />
Ticker.cs
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.ComponentModel;<br />
using System.Drawing;<br />
using System.Threading;<br />
using System.IO;<br />
<br />
namespace Exercice1 {<br />
<br />
public class Ticker : Form {<br />
<br />
Label label1, label2;<br />
<br />
String[] newsItems =<br />
{ "Safest Aerobic Machine Launched",<br />
"First Dog Cloning Is Only Days Away",<br />
"Reviving the Extinct Tasmanian Tiger" };<br />
<br />
String[] businessItems =<br />
{ "FirstMeasure Software to Go Nasdaq",<br />
"MFMF Directors To Meet For The First Time",<br />
"First Sign of Economic Recovery Finally At Sight",<br />
"Euro Hits Record Low (Again)" };<br />
<br />
<br />
<br />
public Thread NewsThread,BusinessThread;<br />
<br />
<br />
public Ticker() {<br />
Initialize();<br />
StartThread();<br />
}<br />
#region Windows Form Designer generated code<br />
private void Initialize() {<br />
this.Height = 100;<br />
<br />
label1 = new Label();<br />
label2 = new Label();<br />
<br />
label1.Width = 280;<br />
label1.Height = 30;<br />
label1.Location = new Point(1, 10);<br />
label1.TextAlign = ContentAlignment.MiddleRight;<br />
<br />
label2.Width = 280;<br />
label2.Height = 30;<br />
label2.Location = new Point(1, 40);<br />
<br />
this.Controls.Add(label1);<br />
this.Controls.Add(label2);<br />
}<br />
#endregion<br />
<br />
private void StartThread() {<br />
<br />
NewsThread = new Thread(new ThreadStart(MoveLeft));<br />
BusinessThread = new Thread(new ThreadStart(MoveRight));<br />
NewsThread.Start();<br />
BusinessThread.Start();<br />
}<br />
<br />
private void MoveLeft() {<br />
string labelText;<br />
while(true)<br />
{<br />
<br />
foreach(string item in newsItems)<br />
{<br />
labelText = item;<br />
label1.Text=labelText;<br />
<br />
for (int i=280;i>1;i--)<br />
{<br />
label1.Location = new Point(i, 10);<br />
<br />
Thread.Sleep(10);<br />
}<br />
<br />
Thread.Sleep(500);<br />
}<br />
}<br />
}<br />
<br />
private void MoveRight() <br />
{<br />
string labelText;<br />
<br />
while(true)<br />
{<br />
foreach(string item in businessItems)<br />
{<br />
labelText = item;<br />
label2.Text="";<br />
int textLength = labelText.Length;<br />
<br />
for (int i=0;i<textLength;i++)<br />
{<br />
label2.Text+=labelText[i];<br />
Thread.Sleep(50);<br />
}<br />
<br />
<br />
Thread.Sleep(500);<br />
}<br />
}<br />
}<br />
<br />
protected override void OnClosing(CancelEventArgs e) {<br />
<br />
NewsThread.Abort();<br />
BusinessThread.Abort();<br />
this.Dispose();<br />
Environment.Exit(0);<br />
<br />
}<br />
<br />
<br />
}<br />
}<br />
<br />
Thank you!
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
This is most likely occurring in your tick event handler. Basically, Windows Forms controls (like your progress bar), and indeed all Win32 common controls, cannot be accessed on a thread other than the thread that created the control. Check out MSDN for Control.Invoke and Control.BeginInvoke.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lies of Our Fathers: A Must-Know About Lent
Judah Himango
|
|
|
|
|
thanks!
I will look into that.
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
You've broken one of the basic rules of Windows UI programming. Only the thread that created the UI can modify the UI. .NET 1.1 doesn't report any exception but I bet you wouldn't have achieved the effect you wanted. .NET 2.0 immediately throws an exception if you try to modify the UI from some other thread.
You'll have to use Invoke/BeginInvoke to marshal the method call on the UI thread.
Regards
Senthil
My Blog
|
|
|
|
|
Hi,
well, the weird thing is that it is actually achieving what I want...After the progressbar finishes, the first window is hidden and the other window opens and you have 2 threads created. One is the right method to move text from right to left and the other is the left method..and they loop forever.
I will try looking into that invoke thing, although I have no idea how it works.
thanks for the tip, I appreciate it
Talal
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."
--Rich Cook
|
|
|
|
|
Hi everybody.
I'm retreiving a DateTime from MS sql server, on two different computers.
Both computers have the same definition in ControlPanel > Regional and language options , and same version of .Net (1.1).
When I cast the DateTime to string, (DateTime.ToString() ), I get on computer #1 mm/dd/yyyy, while in computer #2 I get dd/mm/yyyy.
Where is the problem?
Thanks,
Yaakov
|
|
|
|
|
I am not getting why it is showing differently. Just have a look at you regional settings agian.
And you can use string formats to get your date both date in one format .
DateTime.ToString("dd-MM-yyyy")<br />
or<br />
DateTime.ToString("dd-MMM-yyyy")<br />
or<br />
DateTime.ToString("MMM-dd-yyyy") wiil help you out to get a common format for Dates.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
I know about the formats.
However, this doesn't solve my problem, since I can't modify the entire application.
Thanks anyway.
Yaakov
|
|
|
|
|
hi
i write a web application with c#.
it has some pages and thir controls such as:
validators , datagrid , datalist with template column
and they have thir event handler functions.
the application works correctly on local.
{ my system: [windows 2003 server ]}
but when i upload it to the host server , the events dont work correctly.
------------
site address:http://siteavval.com/WebVDir/MainGrps.aspx
error message for:
javascript__doPostBack('MainGrpsList$_ctl0$LBGrpShr','')
|
|
|
|
|
Hi,
Here i m facing one problem with .net console application.I am having one solution (.net project) now due to our requirement we had made one dll out of that project and then from one another console application i had called that dll.Now problem is that when i am running that another project of console application which is having my project dll ,it is giving the error of system.componentmodel.win32 application after running my console application.
Now Main thing is that one some machine our same application is running without error and on some machine it is givign error which i had describe above so after searching i found that this is error due to .net security now can anybody know how to give right of user which allows my console applicaiton to run without error?
where and how to give rights to user so my application run without errors?
montu3377
|
|
|
|
|
Go into Control Panel, Administrative Tools, Microsoft .NET Framework wizards, Trust An Assembly, then specify your application and give it the necessary trust to run.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Lies of Our Fathers: A Must-Know About Lent
Judah Himango
|
|
|
|
|
in C++ i can pass a function a const reference to an object. i find this is normally a good idea, since it assures me that the function will not make any changes to the objects state.
is there an equivalent concept in C#? if i understand C# correctly all instances of objects are references and initial experiments show they are passed as modifiable references.
i am trying to create a tree of objects (representing the sub directories on a CD-ROM), so that i can say to each child "this is your parent", passing a constant reference to its parent in its constructor. a child cannot alter its parent, so i want to enforce this concept in the code.
i have found a C# article on modifier keywords which led me to discover that i can have a read only object. but putting readonly before the parameter type does not compile
if there is no such concept, how do people express the concept "remember this object, but you cannot modify it?"
zen is the art of being at one with the two'ness
|
|
|
|
|
There is no language support for const function parameters. For your case though, you can declare the parent field in the child class as readonly. That means that it can only be set in the constructor/field initializer. Like this
<br />
class Child : Node<br />
{<br />
private readonly Node parent;<br />
<br />
public Child(Node parent)<br />
{<br />
this.parent = parent;<br />
}<br />
public void SomeFunc()<br />
{<br />
parent = new Node(...);
}<br />
}<br />
Regards
Senthil
My Blog
|
|
|
|
|
Hi,
I import a C++ Dll in my C# application.
First I call from C# a C++ function and then I get
a result set from the dll.
The result is a array with 3 dimensions.
How can I get access this array in C#.
Please help me !
|
|
|
|
|
I need to get a new pixel color starting by a green color and another one over this blue semi-transparent at 50%.
I've readed some articles on this forum but i need just 2 lines of code not warking with whole bitmaps.
I know it is a very simple stuff, but i don't know how fuse or join two pixels getting another colored pixel.
i've tried with
myColor.R = Color.Green.R & Color.Blue.R
myColor.G = Color.Green.G & Color.Blue.G
myColor.B = Color.Green.B & Color.Blue.B
it works but it fuse full blue on green, i need to fuse semitransparent blue instead.
Please help me.
thanks
|
|
|
|
|
|
|
I was hoping other developers could give me some advice as to where to store my data! Previously I have always used classes to maintain information relating to the current process. If a background thread required additional information to process, I usually either passed the information in as a parameter or added properties to my thread class.
Recently I have become aware of CallContext and Thread.SetData. I am sure there are also other "places" that .Net provides for storing information relating to the current process/thread.
My question really is: could someone help me understand the scope and purpose of the different storage mechanisms provided by .Net and why you would use one over the other.
Thanks in advance.
-------------------------------------------------------------------
After some investigation, this is my understanding:
CallContext is visible to all theads where Thread data is only visible to the active thread.
I believe these mechanisms are available as a convenient way to gain access to objects and can be used to avoid the difficulties of making classes visible to eachother. I tend to use Class (static) level objects for this, but I can see in some cases (e.g., usertokens) CallContext would be useful.
- Jeff
|
|
|
|
|
AFAIK, Thread.SetData can be used to store data that you are sure you don't want to share among threads.
Regards
Senthil
My Blog
|
|
|
|
|
Hi all,
I p/Invoke a VC++ dll in C#, but there is serious memory leak, how can I fix the memory leakage by the VC++ dll caused by P/Invoke ?
(the leakage seem not come from the internal C++ code inside the dll, so I suspect it come from the loading and unloading of the dll in C#)
Thanks
|
|
|
|
|
Hi!
If it were like you say everybody would have serious problems using P/invoke.
I think it's very unlikely for the P/invoke mechanism to create memory leaks the dll itself doesn't.
The first time you call a p/invoke function, the containing DLL is loaded and as soon as the class you declared the function in goes out of scope (usually when unloading the AppDomain), the DLL is released.
What exactly are the signatures of your functions and your DllImport declarations?
mav
|
|
|
|
|
Hi All,
I am new to C# programming and need ur help.
How can I view or get an HTML page in my windows forms using C# programming. My project does not want to use any Components or ActiveX controls to achieve this.
Keep Smiling
Thanks & regards,
Neerudi
|
|
|
|
|
Whatever I understood it,Giving u code I think it might help you. If some variable is not initialized just initialize it.
public StreamReader viewofhtml()
{
sURL = this.txthttp.Text;
WebRequest wrGETURL;
wrGETURL = WebRequest.Create(sURL);
WebProxy myProxy = new WebProxy("myproxy",80);
myProxy.BypassProxyOnLocal = true;
wrGETURL.Proxy = WebProxy.GetDefaultProxy();
Stream objStream;
objStream = wrGETURL.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);
return objReader;
}
public void btn_server_Click(object sender, System.EventArgs e)
{
if(this.txthttp.Text == "" )
{
MessageBox.Show("Enter the URL with http://www.google.com");
return;
}
StreamReader tempreader=viewofhtml();
string sLine="";
int i = 0;
while (sLine!=null)
{
i++;
sLine = tempreader.ReadLine();
if (sLine!=null)
{
output +=sLine.ToString();
//this.richTextBox1.Text=output;
}
}
this.txtdisplay.Text=output;
}
|
|
|
|
|