|
Hi thanks for the reply, but i am not getting dataGridAuthorised.Rows property
Any idea
Regards
DilipRam
|
|
|
|
|
I have some Form - and i have some User Control on it.
I have also 6 button on the form and 4 button on the User Control.
In Form code i have some function that collect all the event from all the button ( The Form button and also from the User Control Button) .
My problem is that i need to know in run time witch button send me the event.
I cant use the "Tag" of the button because i using it for other target.
How to do it ?
How can i know if the button is Form relevant or relevant User control ???
Thanks for any help.
|
|
|
|
|
You can use the sender to find out which button was clicked
((Button)sender).Name<br />
|
|
|
|
|
I cant use this way because there are some button with same name on the Form and on the userControl.
I need some way to know who the owner of this button.
Is it the Form OR is it any of the userControls ....
|
|
|
|
|
Use the sender and the ((Control)sender).Parent property together to know which control is.
Visit my blog at http://dotnetforeveryone.blogspot.com/
|
|
|
|
|
Hello,
I would use the 'as' operator for the casting.
Button actButton = sender as Button;
if(actButton!=null)
{
actButton.Name
if(actButton.Parent!=null)
{
if(actButton.Parent is YourUserControl_1)
{
}
else if(actButton.Parent is YourUserControl_2)
{
}
}
}
All the best,
Martin
|
|
|
|
|
|
All the best,
Martin
|
|
|
|
|
You can also check out this thread, which asked almost the same question.
http://www.codeproject.com/script/comments/forums.asp?forumid=387161&Page=3&userid=157870&mode=all&select=2094274&df=100&fr=231.5#xx2094274xx[^]
As others have already pointed out, casting the sender to a Button and then looking at it's properties (name, tag, etc.) to determine which button it is will be the best way to go.
The question that it seems no one asked is why do you need to route 10 buttons through the same event handler? Surely all 10 buttons don't do the same thing? If they actually do different things and you are trying to use 1 event handler to do some common things (like logging, for instance) you would probably be better off to use separate event handlers for each button and then have each event handler call a separate common method.
|
|
|
|
|
hi there,
i made a database on my D drive but i reinstalled the windows and sql server , so what i do now to load that database in my new sql server instance??
Becoming Programmer...
|
|
|
|
|
You need to "attach" the database. This is an operation available in Enterprise Studio (SQL 2000) and SQL Server Manager (SQL 2005). Have a quick search in your help to find out how.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Attach it in your SQL Server.
I Love SQL
|
|
|
|
|
Hello..
I'm having a device on the serial port sending a HEX string (34 46 FF 30) when I use programs like AccessPort I see the string like this "4Fÿ0"
But when I try to get the string in my aplication I get "4F?0" why???
I need to get the "FF/ÿ" HEX/CHAR in my aplication.
The aplication is going to read the 3char in the string and present this in a progressbar.
So I need to get the 3char a Desimal value from 0 to 255.
To do this I use the following code:
strig x = ComPort.ReadExisting();
Console.WriteLine(Convert.ToInt32(ConvertToHex(x.Substring(2, 1)), 16));
public string ConvertToHex(string asciiString)
{
string hex = "";
foreach (char c in asciiString)
{
int tmp = c;
hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
}
return hex;
}
Sorry for my english, hope you understand what I need..
Best regards Svein Jarle
|
|
|
|
|
With this code sample, I get the 4Fÿ0 back
using System;
using System.Collections.Generic;
using System.Text;
namespace TestBytes
{
class Program
{
static void Main(string[] args)
{
Encoding test = Encoding.Default;
string x = "\x34\x46\xFF\x30";
Console.WriteLine("{0}", x);
byte[] bytes = test.GetBytes(x);
for(int i = 0 ; i < bytes.Length ; i++)
{
Console.Write("{0:X2} ", bytes[i]);
}
Console.Write("\n");
Console.ReadLine();
}
}
}
Maybe you are on a different encoding.default ANSI code page on your PC ?
|
|
|
|
|
First of all you must figure out whether the bytes on the cable represent binary
data or textual data. From what you have shown, it seems binary (FF is not
a regular ASCII/ANSI character).
If you want to see it as textual data, you must use the encoding/decoding that
matches the data; only then can you successfully apply the methods ReadChar,
ReadLine, Read(char[]) and the like. The default encoding for SerialPort is ASCII,
which would fail to understand a byte value of FF. See SerialPort.Encoding property.
If you want to capture it as binary data (which implies no interpretation whatsoever)
you should use ReadByte or Read(byte[]). The read will always succeed. But you
would still have to decide how exactly you will deal with the bytes that you have
got; you can be sure though they are identical to what has been received from
the cable.
|
|
|
|
|
Hello..
Thanks for the help.. It is no working..
<br />
if (ComPort.BytesToRead >= 1){<br />
int bytes = ComPort.BytesToRead;<br />
byte[] buffer = new byte[bytes];<br />
ComPort.Read(buffer, 0, bytes);<br />
string hex = ByteArrayToHexString(buffer);<br />
if (hex.Length >= 48) {<br />
Console.WriteLine(hex);<br />
Console.WriteLine(HexStringToCharString(hex));<br />
Console.WriteLine(Convert.ToInt32(ConvertCharToByte(HexStringToCharString(hex).Substring(4, 1)), 16));<br />
}<br />
<br />
}<br />
<br />
<br />
<br />
public string ConvertCharToByte(string asciiString)<br />
{<br />
string hex = "";<br />
foreach (char c in asciiString)<br />
{<br />
int tmp = c;<br />
hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));<br />
}<br />
return hex;<br />
}<br />
<br />
private string HexStringToCharString(string s)<br />
{<br />
StringBuilder sb = new StringBuilder(s.Length / 3);<br />
for (int i = 0; i < s.Length; i += 3)<br />
{<br />
sb.Append(Convert.ToString((char)ushort.Parse(s.Substring(i, 2), System.Globalization.NumberStyles.HexNumber)));<br />
}<br />
return sb.ToString();<br />
}<br />
<br />
private byte[] HexStringToByteArray(string s)<br />
{<br />
s = s.Replace(" ", "");<br />
byte[] buffer = new byte[s.Length / 2];<br />
for (int i = 0; i < s.Length; i += 2)<br />
buffer[i / 2] = (byte)Convert.ToByte(s.Substring(i, 2), 16);<br />
return buffer;<br />
}<br />
<br />
private string ByteArrayToHexString(byte[] data)<br />
{<br />
StringBuilder sb = new StringBuilder(data.Length * 3);<br />
foreach (byte b in data)<br />
sb.Append(Convert.ToString(b, 16).PadLeft(2, '0').PadRight(3, ' '));<br />
return sb.ToString().ToUpper();<br />
}<br />
|
|
|
|
|
I'm trying to create some linq expression manually.
At some stage I want to create an expression to concatenate 2 strings, I'm trying the following code:
using System.Linq.Expressions;
Expression e1, e2;
return Expression.Call(typeof(string), "Concat", new Type[] { typeof(string), typeof(string) }, e1, e2);
this call yield the following error:
System.InvaldOperationExpression
No method 'Concat' on type 'System.String' is compatible with the supplied arguments.
Well, well, I'm somewhat surprised...
what else could I try?
|
|
|
|
|
well, not sure in which forum this question fits.
is there any way or any tool which allows crystal reports to be converted to RDL file,
there are few website which claim to do that, but they provide the services and charge arround $25 per report etc..
Is this the last way i should do it,
i can redesign the entire thing (all reports) but sounds like lot of hectic work to me,
regards,
|
|
|
|
|
It's just converting from one file format to another. The trick is knowing the syntax of both and getting all the nuianses correct. It can be done, but it will take you longer, and cost more than $25.
only two letters away from being an asset
|
|
|
|
|
Hi,
I don't know whether this is the right place to post this query or not.I have a requirment to embadd flash player in a windows form.I am working on C# with VS2005 Version.Can anybody help me where can i get the flash player which supports FLV file formats.
Any help will be greatly appreciated.
|
|
|
|
|
|
Does anybody know how to define a treeview with checkboxes in the nodes using XAML ? The treeview is not bound to a datasource.
Johan Lombaard
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former - Albert Einstein
|
|
|
|
|
I need to be able to delete a log file. However i'm getting the following error:
{System.IO.IOException: The process cannot access the file 'C:\Web_Projects\eServiceRemoteDesktop\bin\Debug\mServiceLog.log' because it is being used by another process. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.File.Delete(String path)
at eServiceRemoteDesktop.frmTimeTicketSync.tlStpBtnClearLog_Click(Object sender, EventArgs e) in C:\Web_Projects\eServiceRemoteDesktop\frmTimeTicketSync.cs:line 229}
(line 229 being the line where i'm trying to do the abovementioned delete file. The emphasis added in the snippet is by me.)
I think that the Logger class we are using does not let go of the log file. I'm not going to be able to make any changes to the logger code though. Is there any other way to make this delete happen?
Two Thumbs Up!!
Mihir Karkare
|
|
|
|
|
Hello,
Looks like your Logger class uses some kind of Stream, which doesn't get closed.
This is not good practice.
It is sometimes the case if an exception is thrown during stream write, your file stays also locked.
For this cases you could use an external program which unlocks the file (Only use it if it's really an "emergency")
http://www.chip.de/downloads/c1_downloads_18414122.html[^]
You could start this over the Process and ProcessStartInfo class of System.Diagnostics.
unlockerprocess.FileName = "unlocker.exe";
unlockerprocess.Arguments = filename + " /s /o";
All the best,
Martin
|
|
|
|
|
If you programmatically fail to delete a file, insert a Thread.Sleep(5000);
just before your File.Delete().
If that helps, ask and I will repeat the explanation upon your request.
|
|
|
|