|
Hi Appelz,
Following code will get you the text in the DataGrid cell where mouse is being clicked.
Paste the following code in MouseUp event of the DataGrid Control.
private void DataGrid1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
System.Drawing.Point pt = new Point(e.X, e.Y); <br />
DataGrid.HitTestInfo hti = DataGrid1.HitTest(pt); <br />
<br />
if(hti.Type == DataGrid.HitTestType.Cell) <br />
{ <br />
string str = "";<br />
str = DataGrid1[hti.Row, hti.Column].ToString();<br />
MessageBox.Show(str);<br />
} <br />
<br />
}
Do revert back, whether you could achieve the functionality or not.
Regards,
Jay.
|
|
|
|
|
yes thank you it works well
But i put what is in the messagebox, in a textbox so it can be edited.
Now i added a button and if you click on it i want the data added in the textbox back into the grid (in the right cell).
is this possible or too difficult because i can't make it work?
|
|
|
|
|
Hi Appelz,
try the code below
DataGrid1[hti.Row, hti.Column]=textBox1.Text;<br />
DataGrid1.Invalidate();
Regards,
Jay
|
|
|
|
|
Hello there
I have a Winform whit a birth date field that I enter
I want to get Pup up Form Whit a 1 week reminder off all my birth date of all my customers & I want an also 3 day remind & at the same date
Exsmpale : if i enter that Tomi birthdate is in 15/08/1974
i want pupup that remind me in 10/08/2004 in 13/08/2004 in
15/08/2004
how can I do it ?
I am working whit a Accses Database & C#
thanks allot to all...
please help...
|
|
|
|
|
Hi!!!
Some body know how to write some algoritm to compress text strings???
Greetings
S_W
|
|
|
|
|
Hi,
I'm looking for an event / function that gets called when your assembly gets loaded.
The problem now is that I declare a static member variable in a class which only gets initialised when the class is explicitly used. This variable however has to be initialised for every class which is used in the assembly, but without having to go through the trouble of putting code in every class' constructor.
The reason why this variable has to be initialised when the assembly gets loaded and before any class is constructed is because this variable init checks whether the user has a valid license to use this assembly.
Thanks very much in advance,
Arthur van der Wal
|
|
|
|
|
Hello,
I am wondering if you ever found an answer to this question? I wish to do the same thing.
Tanks for your support
Pat O
<a href="http://currentchaos.blogspot.com/">Blog</a>
_ _ _
|
|
|
|
|
Hi, I have created a windows application which shows a system tray icon and some menu on it. When i run it by doubl click it runs perfect icon is visible in system tray. I put that exe path in registry "HKEY_LOCAL_MACHINE\Microsoft\Windows\CurrentVersion\Run". So when user login to the system my application starts running in the background but it doesnt show icon in the system tray.
Urgent reply required.
Thanks
|
|
|
|
|
hai there,
if i am debuging my widows or console application. Then i can notice the current values of variables that i am using in my application. my question is how can i view the values of
ArrayList, Hash Table or any Sorted List.
Appart from this view the Flow of Execution ?
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
Look down in the "autos" section. Look at the variable naming one of your data structure variables. It should have a little expandable plus sign-- click on that and you will see the values it contains.
Regards,
Jeff Varszegi
|
|
|
|
|
Word of warning to the original poster, though - this doesn't work very well at all for Hashtable s. You have to dig deep to find any relevant data.
In VS.NET 2005, they are adding new debug views, such as extensible tooltips and data viewers to solve problems such as this. DataSet s are also difficult to debug so they would have a view associated with them that lets you view (and modify) the XML data in a text box or view it using MSXML hosted in Internet Explorer, as well as a generic DataGrid (last time I checked).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Word of warning to the original poster, though - this doesn't work very well at all for Hashtables. You have to dig deep to find any relevant data.
I'm using VS.NET 2003, and it works-- although it's a little confusing. The top "twistie" expands to show all the entries (haven't tried it on large numbers of entries), and then each one of those expands to show the details of the data element of the mapping. I seem to remember once trying to peer into a Hashtable during debugging on 2002 and having the IDE hang, but at least that's not happening now.
Regards,
Jeff Varszegi
|
|
|
|
|
I know it works, but the important part was "well". Perhaps I mis-phrased, but that's basically what I meant: that it was a little - as you put it - "confusing".
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I wonder if there is a difference in view between the regular watch window and the one used by quick watch. The quick watch one doesnt seem to show me the obvious details like you mentioned(lot of digging around to get to the data gives a really frustrating experience) I got to try with the watch window though.
|
|
|
|
|
I rarely use the watch windows at all. Try the Autos, Locals, and This debugging windows. Autos uses the variables relevent to the current line you're debugging; locals is all the variables in the current scope (including fields, IIRC); and This is all the variables for the current object you're debugging. They show you a lot of information and don't constrain you to whatever you put (or forget to put, more importantly) in the watch windows.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hai there,
how can i call a console window and console result(out put) in windows application.
hai, feel free to contact
Sreejith SS Nair
|
|
|
|
|
In VS if u make the target app a console app and in your main form make ti load just like a windows app it will load both the console window and the windows form. Best way to do it is to. Make a windows form application then goto project proporties and change ti from windows app to console. Then you can use Console.writeline(); and watch the code. Might be other ways too though.
|
|
|
|
|
for a static mothed in java i can synchronize this way :
public class A {
public synchronized static void f () {
//do something
}
}
but how can i do this in C# ?I want to use the keyword "lock",but for a static method you can't use "this" .
Can the below method work?
public class A {
public static void f () {
lock ( typeof (A) )
{
//do something
}
}
}
|
|
|
|
|
Yep, that will work. I usually create an extra object to lock on, though, whether I'm working in a static or instance context; that goes for Java, too. Why? Because I think that an object should control its own destiny; its code shouldn't block indefinitely because some jerkoff decided to write code that locked the object or class externally. Unless that's desired behavior, of course. Know what I mean, though? Check out the SyncRoot property, where the .NET designers apparently decided the same thing. The same sort of thinking is exposed in Java APIs too.
Obviously, if you're creating a zillion objects that may be locked on, you don't want to create an extra object for each one just to accomplish this. However, I try to avoid creating zillions of objects in my code anyway; this means that most of my objects, especially the ones that I need to synchronize on, are pretty large and/or long-lived, hence the overhead of creating a tiny empty object is negligible. Add to that judicious use of the Immutable Object pattern, and I'm able to synchronize "cleanly" with no appreciable overhead.
[EDIT]One more thing-- even if you're going to use the type itself to lock on in a static context, you should probably store it as a static variable instead of getting it over... and over... and over again. [/EDIT]
Regards,
Jeff Varszegi
|
|
|
|
|
Actually, using typeof(MyType) to lock against - while not a good idea (see Mike's reply, which I read about on MSDN some time back) - is fine. The typeof operator simply gets a handle to the type, which requires only two instructions as opposed to the one or two instructions (depending on the current state of the stack) to load the field.
Still, though - like you said - it's better to have a separate object to lock against at least for static methods. Locking against this for instance methods is still okay, but - as you said (again) - a separate object is often more desirable.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Yep. It's often more desirable for instances, not less, because it's more likely when you're working on a large project that some slob will decide to lock on the objects of your class.
Java (and J#, I guess; dunno) is pretty strange in that its synchronization keyword, synchronized , can be used directly in the method signature, for both static and instance methods. I'll never forget the day that I discovered that the static one locked the type itself; it seemed pretty dumb, and almost all of the documentation released from Sun that treats of synchronization just uses the keyword in the method declaration. I guess their rationale is that you don't have to lock on something like the type if you don't want to, but it still seems pretty dumb.
So you're saying that typeof is fast? I haven't checked out the IL for any of this or actually tested it. The article Mike pointed out says that typeof is slow.
Regards,
Jeff Varszegi
|
|
|
|
|
The main reason the article discusses is that you shouldn't use it because it could create a race condition and dead-locking. As far as slow, I'm not sure about that. I supposed Dr. GUI would know better than I (or rather, his "nurses" as he calls them from time to time) but in my experience it seems okay. The instruction cound - while I know isn't everything - is really no different (for instance, if you locked against a property it could be from 2 to 5 instructions as opposed to 1 to 2 for a field). And getting a handle to the type I can't believe would be that slow. I could be wrong, though.
Anyway, the biggest reason not to use it because of the potential deadlocks that could occur.
To the original poster - if you're following along - you can see we all agree: don't use it!
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Another good reason to lock on internal objects is that it frees you to lock on different objects for different purposes. This is a technique I use a lot to increase performance. If two different things can be changed simultaneously in a multithreaded situation, without affecting the integrity of your object, but both of them need synchronization, you should consider locking on separate objects.
Regards,
Jeff Varszegi
|
|
|
|
|
Hi
I am looking for a way to evaluate expression. An expression return exacly one result. The result may be a boolean, a number value a string, etc.
The idea is I give my user a tool to define expression. The expression is built in MSSQL style, and can use SQL functions. For example:
$Num1 > 100 AND $Num2 < 0
At run time my program replaces the variables with values, for example:
101 > 100 and 1<0
In the past, my application ran on the server. I used SQL itself for that: I passed it the string, received the return value and it was great.
No I am writing a client-server application, and this code runs on the client. So I cannot go to the server all the time.
Is there a way/class/object I can pass there expressions to on the client? I was thinking of using a dataset, but I can only see it can select records from a given data table. I cannot find how to perform such calculations.
Thank you!
|
|
|
|