|
hi ...
I think your code is fine
but
sneha01 wrote: Com.ExecuteNonQuery();
????
sorry for this , check what you wrote here Com
I know nothing , I know nothing
|
|
|
|
|
SqlCommand SpCmd = new SqlCommand("Select * from Table ");
this is may be wrong. When CommanType is StoredProcdure, you have to give the stor proc name:
though u are setting CommandText later check it out.
The culprit i feel is ExecuteNonQuery(). it should have been ExecuteQuery()
rAm
i Think, i Wait, i Fast -- Siddartha
|
|
|
|
|
Hi,
I start a process using the Process.Start method with appropriate arguments.
I can see that the process is created.
However, when I try to get a handler on the process's main window , I get 0.
It seems to be because the process doesn't already have finished drawing itself.
How can I resolve this problem ?
Thanks !
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Hi
Hope this will help you
even if I had a feel that my way is stupid ...
bool GetHandle;<br />
GetHandle= false;<br />
int WaitingTime = 100;<br />
Process pr = Process.Start("NotePad.exe");<br />
while (GetHandle)<br />
{<br />
if (pr.StartTime.Ticks <= (DateTime.Now.Ticks - WaitingTime))<br />
{<br />
GetHandle = true;<br />
}<br />
}<br />
MessageBox.Show (Handle.ToString());
Have a good day ....
I know nothing , I know nothing
|
|
|
|
|
I'm going to try ur suggestion.
There's no stupid idea ! never !
Thanks a lor for helping.
I'll be back with comments.
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Since you start by intializing GetHandle to false, we'll never enter in the while loop. No ?
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
yeah yeah you right x10 , sorry
I just write it fast , you can fix the loop right ?
and may be you can use
for (int i =0 ; i<= 1000 ; i++)
{
Application.DoEvents();
}
it's just about the idea , agree ?
I know nothing , I know nothing
|
|
|
|
|
Yeah, you're right !
What about the following little modification of your first code ?
bool getHandle = true;
int waitingTime = 300;
while (getHandle)
{
if (InterProcCommunication.CurrentProcess.StartTime.Ticks <= (DateTime.Now.Ticks - waitingTime))
{
getHandle = true;
}
else
{
getHandle = false;
}
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
We can also use Thread.Sleep(time);
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Uhhh...Instead of going through the timer garbage, which can be unreliable depending on system load, why not just do it in a single line of code?
Process newProc = Process.Start(newProcessInfo);
newProc.WaitForInputIdle();
Doc on it are here[^].
|
|
|
|
|
cool !! man , I didn't know that
it's just awesome
I know nothing , I know nothing
|
|
|
|
|
This is interesting ! It does the same thing than using the Thread.Sleep(time) with a constant check of the handle on the process's main window, but in BETTER and MORE SIMPLE.
Thanks !
p.f. Goudjo-Ako
Bringing our energy together !
|
|
|
|
|
Is there a way to prevent edit of some columns in a DataGridView bound to a DataTable?
What I need is prevent edit, the user shouldn't have the opportunity to enter in edit mode if the celll belongs to one of the columns I consider "Read Only".
|
|
|
|
|
Hi
As far as I know ... this is can't be done in C# (2003 ) .net 1.1
but I know a cool and open Source DataGrid for .net 2.0 can solve this prb
check this link
www.codeproject.com/cs/miscctrl/csharpgridcontrol.asp
and sorry if I got so far from your Question ....
I just wanted to help .....
I know nothing , I know nothing
|
|
|
|
|
If this helps anybody I captured the DataGridView.CellParsing event and forced a EndEdit()
Not very elegant but it prvents user from entering anything
|
|
|
|
|
Hi Johnny,
Tables(0).Columns(0).ReadOnly= True
Now bind this datatable to the Datagridview. The column 0 is readonly and will not enter into edit mode.
rAm
i Think, i Wait, i Fast -- Siddartha
|
|
|
|
|
Hi,
How can I take the list of all users in my domain?
Regards
Michal
|
|
|
|
|
Hi
may be Mr.Thund3rstruck can help you more than any body else ...
check his Topic here ..
http://www.codeproject.com/useritems/everythingInAD.asp?msg=2000802
Have a good day ...
I know nothing , I know nothing
|
|
|
|
|
Anyone got idea how to create blinking I-Beam cursor like one that has textbox when it receive focus? Can I do it trough unmanaged code or I need to implement it with timers/overriding OnPaint event?
Thanks,
Ivan.
|
|
|
|
|
Hi ....
I hope this Example will help you ...
I used 2 Files
- mycaret.cs (Class)
- caretsample.cs ( Example How to use it ) Optional
File : mycaret.cs
<br />
using System;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
using System.Drawing;<br />
<br />
public class MyCaret {<br />
[DllImport("user32.dll")]<br />
public static extern int CreateCaret(IntPtr hwnd, IntPtr hbm, int cx, int cy);<br />
[DllImport("user32.dll")]<br />
public static extern int DestroyCaret();<br />
[DllImport("user32.dll")]<br />
public static extern int SetCaretPos(int x, int y);<br />
[DllImport("user32.dll")]<br />
public static extern int ShowCaret(IntPtr hwnd);<br />
[DllImport("user32.dll")]<br />
public static extern int HideCaret(IntPtr hwnd);<br />
<br />
Control ctrl;<br />
Size size;<br />
Point pos;<br />
bool bVisible;<br />
<br />
public MyCaret(Control ctrl) {<br />
this.ctrl = ctrl;<br />
Position = Point.Empty;<br />
Size = new Size(1, ctrl.Font.Height);<br />
Control.GotFocus += new EventHandler(OnGotFocus);<br />
Control.LostFocus += new EventHandler(OnLostFocus);<br />
<br />
if (ctrl.Focused)<br />
OnGotFocus(ctrl, new EventArgs());<br />
}<br />
<br />
public Control Control {<br />
get { return ctrl; }<br />
}<br />
<br />
public Size Size {<br />
get { return size; }<br />
set { size = value; }<br />
}<br />
<br />
public Point Position {<br />
get { <br />
return pos; <br />
}<br />
set { <br />
pos = value; <br />
SetCaretPos(pos.X, pos.Y);<br />
}<br />
}<br />
<br />
public bool Visible {<br />
get {<br />
return bVisible;<br />
}<br />
set {<br />
bVisible = value;<br />
if (bVisible)<br />
ShowCaret(Control.Handle);<br />
else<br />
HideCaret(Control.Handle);<br />
}<br />
}<br />
<br />
public void Dispose() {<br />
if (ctrl.Focused)<br />
OnLostFocus(ctrl, new EventArgs());<br />
Control.GotFocus -= new EventHandler(OnGotFocus);<br />
Control.LostFocus -= new EventHandler(OnLostFocus);<br />
}<br />
<br />
private void OnGotFocus(object sender, EventArgs e) {<br />
CreateCaret(Control.Handle, IntPtr.Zero, Size.Width, Size.Height);<br />
SetCaretPos(Position.X, Position.Y);<br />
Visible = true;<br />
}<br />
<br />
private void OnLostFocus(object sender, EventArgs e) {<br />
Visible = false;<br />
DestroyCaret();<br />
}<br />
}<br />
caretsample.cs
<br />
using System;<br />
using System.Drawing;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Runtime.InteropServices;<br />
<br />
public class MyForm : Form {<br />
private Container components = null;<br />
MyCaret caret;<br />
string[] lines;<br />
Point cur;<br />
Point org;<br />
bool bSel;<br />
<br />
public MyForm() {<br />
InitializeComponent();<br />
<br />
caret = new MyCaret(this);<br />
lines = new string[] {<br />
"public class MyApp {",<br />
" System.Console.WriteLine(\"Hello,World\");",<br />
"}"};<br />
cur = Point.Empty;<br />
org = Point.Empty;<br />
bSel = false;<br />
}<br />
<br />
protected override void Dispose( bool disposing ) {<br />
if( disposing ) {<br />
if (components != null) {<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e) {<br />
base.OnPaint (e);<br />
StringFormat fmt = StringFormat.GenericTypographic;<br />
fmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;<br />
for (int i = 0; i < lines.Length; ++i)<br />
e.Graphics.DrawString(lines[i], Font, new SolidBrush(this.ForeColor), <br />
0, Font.Height * i, StringFormat.GenericTypographic);<br />
if (bSel) {<br />
DrawSelected(e.Graphics);<br />
}<br />
}<br />
<br />
protected override void OnKeyDown(KeyEventArgs e) {<br />
if (e.Shift) {<br />
if (!bSel) {<br />
org = cur;<br />
bSel = true;<br />
}<br />
}<br />
else {<br />
org = cur;<br />
bSel = false;<br />
}<br />
<br />
switch (e.KeyCode) {<br />
case Keys.Left:<br />
if (cur.X > 0) <br />
--cur.X;<br />
else if (cur.Y > 0) {<br />
--cur.Y;<br />
cur.X = lines[cur.Y].Length;<br />
}<br />
break;<br />
case Keys.Right:<br />
if (cur.X < lines[cur.Y].Length)<br />
++cur.X;<br />
else if (cur.Y < lines.Length - 1) {<br />
++cur.Y;<br />
cur.X = 0;<br />
}<br />
break;<br />
case Keys.Up:<br />
if (cur.Y > 0) {<br />
--cur.Y;<br />
if (cur.X > lines[cur.Y].Length)<br />
cur.X = lines[cur.Y].Length;<br />
}<br />
break;<br />
case Keys.Down:<br />
if (cur.Y < lines.Length - 1) {<br />
++cur.Y;<br />
if (cur.X > lines[cur.Y].Length)<br />
cur.X = lines[cur.Y].Length;<br />
}<br />
break;<br />
}<br />
MoveCaret();<br />
Invalidate();<br />
}<br />
<br />
void DrawSelected(Graphics g) {<br />
Point bgn;<br />
Point end;<br />
<br />
if (org.Y < cur.Y || org.Y == cur.Y && org.X < cur.X) {<br />
bgn = org;<br />
end = cur;<br />
}<br />
else {<br />
bgn = cur;<br />
end = org;<br />
}<br />
<br />
int p;<br />
int q;<br />
PointF lt = PointF.Empty;<br />
PointF rb = PointF.Empty;<br />
for (int i = bgn.Y; i <= end.Y; ++i) {<br />
lt.Y = i * Font.Height;<br />
rb.Y = (i + 1) * Font.Height;<br />
<br />
if (i == bgn.Y) { <br />
lt.X = CalcWidth(g, lines[i].Substring(0, bgn.X));<br />
p = bgn.X;<br />
}<br />
else { <br />
lt.X = 0; <br />
p = 0;<br />
}<br />
if (i == end.Y) {<br />
rb.X = CalcWidth(g, lines[i].Substring(0, end.X));<br />
q = end.X;<br />
}<br />
else {<br />
rb.X = CalcWidth(g, lines[i]);<br />
q = lines[i].Length;<br />
}<br />
g.FillRectangle(Brushes.DarkBlue, lt.X, lt.Y, rb.X - lt.X, rb.Y - lt.Y);<br />
g.DrawString(lines[i].Substring(p, q - p), Font, new SolidBrush(Color.White), <br />
lt.X, lt.Y, StringFormat.GenericTypographic);<br />
}<br />
}<br />
<br />
float CalcWidth(Graphics g, string s) {<br />
StringFormat fmt = StringFormat.GenericTypographic;<br />
fmt.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;<br />
SizeF size = g.MeasureString(s, Font, Point.Empty, fmt);<br />
return size.Width;<br />
}<br />
<br />
void MoveCaret() {<br />
using (Graphics g = Graphics.FromHwnd(Handle)) {<br />
float w = CalcWidth(g, lines[cur.Y].Substring(0, cur.X));<br />
caret.Position = new Point((int)w, Font.Height * cur.Y);<br />
}<br />
}<br />
<br />
private void InitializeComponent() {<br />
this.AutoScaleBaseSize = new System.Drawing.Size(6, 12);<br />
this.ClientSize = new System.Drawing.Size(292, 266);<br />
this.Font = new System.Drawing.Font("MS ゴシック", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
<br />
}<br />
<br />
[STAThread]<br />
static void Main() {<br />
Application.Run(new MyForm());<br />
}<br />
}<br />
<br />
<br />
have a good day ...
I know nothing , I know nothing
|
|
|
|
|
|
I see this same #$%# in lotsa managed code (see SharpDevelop too)! Why??? A managed caret is just as easy to make...
|
|
|
|
|
Is one better than the other? I have done some research and found that if I have a ClassA that overloads the '==' operator then using ClassA == null will actually go into that overload operator function, but object.Equal(ClassA,null) does not go into the overloaded '==' operator function. Furthermore, what is really weird is if I say ClassA myClassA; in my code and do not set it. myClassA equals null and then coding if (myClassA == null);. My overloaded '==' operator function will get called and I HAVE to use object.Equal(myClassA,null). I cannot use if (this == null && myClassA == null) return true; within my overloaded '==' operator function because it would go into an infinite loop.
Another thing which I think is weird is using object.Equal() instead of ==, I will sometimes get a Code Analysis warning CA1062 (Ex: Microsoft.Design : Validate parameter 'value' passed to externally visible method GettingControlEventArgs.set_Control(Control):Void. So in my code if I do not want the overloaded == operator to get called if myClassA is null then I first must ust object.Equal() and then use == to test if myClassA is null to get rid of the Code Analysis warning.
Chris
|
|
|
|
|
chris175 wrote: Is one better than the other?
The better one is the one that does exactly what you want to do...
if I have a ClassA that overloads the '==' operator then using ClassA == null will actually go into that overload operator function, but object.Equal(ClassA,null) does not go into the overloaded '==' operator function.
You are not talking about overloading, but overriding. Overloading is when you have more than one method with the same name but with different parameters.
Both the == operator and the Equals method can be overridden, and using either on the object will use the overridden one. If you override the == operator, you should also override the Equals method (and also the != operator and the GetHashCode method).
If you use Object.Equals , you have specified that it should use the static method in the Object class. Static methods can not be overridden.
Furthermore, what is really weird is if I say ClassA myClassA; in my code and do not set it. myClassA equals null
Only if you declare the variable in a class. If you declare it as a local variable in a method, it will be undefined, and the compiler will prevent you from using it before assigning it a value.
and then coding if (myClassA == null);. My overloaded '==' operator function will get called and I HAVE to use object.Equal(myClassA,null).
No, you don't HAVE to. You can simply cast your object to Object :
if ((object)myClassA == null)
This will use the == operator of the Object class instead of the overridden == operator.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: You are not talking about overloading, but overriding
But the custom operator implementation must be a static method, which doesn't fit in with overriding. Even MSDN talks about overloading[^] operators, not overriding them.
|
|
|
|
|