|
Where does GenericButton come from?
What you should do is take sender and cast it back to a button:
<br />
Button TheButtonThatWasClicked = (Button) Sender;<br />
Then you can access all the properties of that button:
<br />
string name = TheButtonThatWasClicked.Name;<br />
string text = TheButtonThatWasClicked.Text;<br />
object tag = TheButtonThatWasClicked.Tag;<br />
I included Tag there because tag is a handy property of certain controls that you can use to store any object you want and be able to retrieve it later.
|
|
|
|
|
Hi,
I would like to loop through the following XML file to fill a combobox with the client name value. Does anyone know how to do this and where is an example?
FTP
Client>
Client_Name xmlns="Default1" /
/Client
Client
Client_Name xmlns="Default2" /
/Client
/FTP
Thanks in advance.
Stephen
-- modified at 15:36 Tuesday 1st November, 2005
|
|
|
|
|
Create a DataSet Object and then
<br />
ds.readXml("Path");<br />
for (int i=0;i < ds.tables(0).rows.count;i++)<br />
{<br />
cmbClientName.Items.Add(ds.Tables(0).Rows(i).Items("[Client Name]")<br />
}<br />
Regards
Rizwan Ahmed Malik
R A M
-- modified at 0:31 Wednesday 2nd November, 2005
|
|
|
|
|
|
Hello,
I have:
<br />
foreach(DataColumn col in this.dataview.Table.Columns) { <br />
ColumnIndex++;<br />
.<br />
.<br />
. <br />
} <br />
Is there a way of getting the col HeaderText (not col.ColumnName) within this foreach statement?
Thank you.
|
|
|
|
|
DataColumn doesn't have a HeaderText property. What you are probably looking for is the HeaderText of a DataGridColumnStyle. Try something this:
<br />
foreach(DataGridColumnStyle dgcs in MyDataGrid.TableStyles["MyTable"].GridColumnStyles)<br />
{<br />
string headertext = dgcs.HeaderText;<br />
.<br />
.<br />
.<br />
}<br />
-- modified at 16:51 Tuesday 1st November, 2005
|
|
|
|
|
|
I'm trying to find the straight forward way to sort a single array of dates.
string[] datearray = new string[10]
here is a sample...
i want this:
12/27/2005
12/28/2005
01/01/2006
01/02/2006
01/04/2006
01/05/2006
12/29/2005
12/30/2005
12/31/2005
01/03/2006
to look at this:
12/27/2005
12/28/2005
12/29/2005
12/30/2005
12/31/2005
01/01/2006
01/02/2006
01/03/2006
01/04/2006
01/05/2006
any clues?
|
|
|
|
|
Why are you storing them as strings instead of DateTimes?
Jon Sagara
Look at him. He runs like a Welshman. Doesn't he run like a Welshman? Doesn't he? I think he runs like a Welshman.
Sagara.org | Blog | My Articles
|
|
|
|
|
thats all you needed to say... i fixed it. I needed the output in string format so i had a brain fart and started converting it early... thanks
|
|
|
|
|
I'm looking to access some file properties such as the Author and comments. Where is this information stored? Is there a .Net class that allows access?
|
|
|
|
|
Have you tried hte FileInfo Class?
|
|
|
|
|
I have but it does not expose the information that I'm looking for.
For example if you right click a file choose properties then choose the summary tab. The information that might be present here is what I'm after.
|
|
|
|
|
In that case you'll probably have to pinvoke a win32 api call to do this. You might want to try asking in the c++ forum since win32 is provided as c++ style dlls and 'documented' as .h files.
|
|
|
|
|
Simple question--one would think (...but I'm pulling my hair out).
I'm trying to drag a control (say a button) in a Windows app at runtime.
The button, as I drag it, appears to split into two button images (with each
"instance" having its location updated about half the time.)
My code, in the Form1 class:
-----------------------------------------------------
bool isDragging = false;
Point anchor;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isDragging = true;
anchor = new Point(e.X,e.Y);
}
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left && isDragging)
{
button1.Location += new Size(e.X-anchor.X, e.Y-anchor.Y);
anchor = new Point(e.X,e.Y);
}
}
-----------------------------------------------------
Please save my hair!!
THANKS,
Tom
|
|
|
|
|
|
If i want to store a value in the registry,somthing like:
[Intalation path]+"\\HelpFiles\\Help.htm"
How would i get the inatalation so i can enter it into the setup project registry editor?
Thanks.
|
|
|
|
|
I have an application that retrieves data from a socket. The process is periodically not returning any results. I have tried the following methods for connecting to the socket in an attempt to resolve the issue but have been unsuccessful. Is this a problem in my code or is it related to network issues? What can be done to better track this issue and resolved it?
Code Option #1
<br />
Dim Client As System.Net.Sockets.TcpClient<br />
Dim netStream As NetworkStream<br />
''
Client = New System.Net.Sockets.TcpClient<br />
Client.NoDelay = False<br />
Client.Connect(Switch.IPAddress, Switch.Port)<br />
netStream = Client.GetStream()<br />
''
Do<br />
numberOfBytesRead = netStream.Read(bytes, 0, uCVT.IntNulls(Client.ReceiveBufferSize))<br />
Loop While netStream.DataAvailable<br />
''
If Not netStream Is Nothing Then netStream.Close()<br />
If Not Client Is Nothing Then Client.Close()
Code Option #2
<br />
Dim Socket As Socket<br />
''
Socket = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)<br />
Dim rEP As New IPEndPoint(IPAddress.Parse(Switch.IPAddress), Switch.Port)<br />
Socket.Connect(rEP)<br />
''
Dim bytes(1024) As Byte<br />
Dim bytesRec As Integer = Socket.Receive(bytes, 0, Socket.Available, Net.Sockets.SocketFlags.None)<br />
''
If Not Socket Is Nothing Then Socket.Close()
Thank you,
Jason W.
|
|
|
|
|
I'm confused on the following:
public class mydef
{
int int1;
int int2;
...
pubic void SetValues(int f, int s)
{...}
}
mydef myobj;
myobj.SetValues(1,2);
mydef myobj2;
myobj2 = myobj; // CAN I DO THIS?
myobj.SetValues(3,4);
... What have I just done?
Is it as straight forward as it seems? Did I simply set the values in myobj, create a new object and set it's values to those in myobj, and then modify the values in myobj without affecting myobj2?
If not, how would I do this?
|
|
|
|
|
You set the myObj2 variable to reference the value pointed to by myobj variable. Is that what you intended to do?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Morality Apart from God
Judah Himango
|
|
|
|
|
No, that is not what I intended to do.
What I would like to do, is to copy all the fields from myobj into myobj2 without setting them to the same object reference.
|
|
|
|
|
Because mydef is a class, all your variables (myobj, myobj2 ) are references to the same object.
budidharma wrote: myobj2 = myobj; // CAN I DO THIS?
You can do that, but now myobj2 and myobj both point to the same object. So
myobj.SetValues(3,4); is the same as myobj2.SetValues(3,4);
If mydef was a struct, and you did myobj2 = myobj; ,
myobj2 was a different object than myobj (someone pleas correct me if i'm wrong). myobj is then sort of copied to myobj2 .
Hope this makes sense
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
That's what I was afraid of. I don't want to set myobj2 to the location in memory of myobj. I want to copy all the data from myobj into myobj2.
I don't want this to be written as structs.
I know I could simply write a copy function:
public static void Copy(mydef myobj, mydef myobj2)
{
myobj2.Set(myobj.Get())
}
But that's a very long winded and very ... not elegant.
What's the better method of doing this in C#?
|
|
|
|
|
The usual/recommended way is to implement IClonable.Clone . What i usually do is something like this:
public class MyDef : IClonable {
...
protected MyDef(MyDef original){
}
public object Clone {
return new MyDef(this)
}
public static MyDef Copy(MyDef original){
return new MyDef(original)
}
...
}
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
-- modified at 12:28 Tuesday 1st November, 2005
|
|
|
|
|
Thank you. Above what you wrote is how I was thinking about doing it.
But now that you've mentioned the ICloneable interface, I'd like to learn that method as well.
I've been searching for a tutorial on this for over an hour, and have not found one. I'm not exactly how to use it.
Can you explain a little bit about this? Thanks.
|
|
|
|