|
You have to cast it since it returns an object:
(myServerArrayList[0] as myServerInfo).strServerName
|
|
|
|
|
This works perfect!
Thanks a lot
|
|
|
|
|
make sure you only have serverinfo in that arraylist though
item as ServerInfo will return null if item is not a serverinfo, this will create a runtime error. If you can and you are using 2005 i would try to use one of the generic collection types Collection<serverinfo> or List<serverinfo> as someone else suggested later. That's more likely to show errors at compile time.
HTH
Russ
|
|
|
|
|
Thanks a lot for this detailed information!!
|
|
|
|
|
Arrays store System.Object type. When you add a new object or an item of promotive type they will be upcasted to System.Object. This is the line inside ArrayList which adds the new item:
public virtual int Add(object value); Use Code DEfinition Window in VS 2005 to see what's inside ArrayList class.
In order to access properties you need to down cast the array item you want to acces like:
Console.WriteLine(((ServerInfo)myServerArrayList[0]).PropertyName);
You would have the same problem if you tried:
ArrayList myList = new ArrayList();
int int1 = 1;
myList.Add(int1);
int int2 = 2;
myList.Add(int2);
int int3 = myList[0]; // oops error - cannot convert type 'object' to 'int'
int int3 = (int)myList[0]; // this will do the trick
Happy coding ...
|
|
|
|
|
Hi.
Does anyone know how can I make a control work without recieving the focus?
The thing is that I'm trying to simulate a kyboard (on a UserControl) which is added to a form. Whenevet a key is clicked, I use the SendKeys.SendWait method to simulate a keystroke. In order to process the simulated keystroke, the recieving form should be in focus. To achieve this, I use the SetFocus function (from User32.dll) with the handler of the recieving form. So far so good - it all works fine except for the slight occasional control bar flicker when changing the focus.
So - is there a way to avoid all that focus transfer?
|
|
|
|
|
hi all,
i have a Tree with 3 modes. each tree has 1 child. i need to create 2 context menus;one for all the nodes and the other for all the children programmatically
kindly help
Sonu
|
|
|
|
|
Hi,
have a look to my example:
I created a windows-application with a form
and one 'TreeView'-component named treeView1 in my code.
The only code is written within the Load-event of the form:
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
ContextMenu myRootContextMenu = new ContextMenu();<br />
myRootContextMenu.MenuItems.Add("Edit Root");<br />
<br />
ContextMenu myChild1ContextMenu = new ContextMenu();<br />
myChild1ContextMenu.MenuItems.Add("Edit Child 1");<br />
ContextMenu myChild2ContextMenu = new ContextMenu();<br />
myChild2ContextMenu.MenuItems.Add("Edit Child 2");<br />
<br />
<br />
TreeNode rootTreeNode = new TreeNode("Root");<br />
rootTreeNode.ContextMenu = myRootContextMenu;<br />
rootTreeNode.Nodes.Add("First Node");<br />
rootTreeNode.Nodes[0].ContextMenu = myChild1ContextMenu;<br />
rootTreeNode.Nodes.Add("Second Node");<br />
rootTreeNode.Nodes[1].ContextMenu = myChild2ContextMenu;<br />
<br />
treeView1.Nodes.Add(rootTreeNode);<br />
}<br />
I created one root treenode 'rootTreeNode'
TreeNode rootTreeNode = new TreeNode("Root");
and
added two child nodes:
rootTreeNode.Nodes.Add("First Node");<br />
rootTreeNode.Nodes.Add("Second Node");
After that, I added this treenode to the TreeView 'treeView1'
of the Form.
treeView1.Nodes.Add(rootTreeNode);
Now we come to the context-menues:
I created one root context-menu, and gave it a description
ContextMenu myRootContextMenu = new ContextMenu();<br />
myRootContextMenu.MenuItems.Add("Edit Root");
and with the property 'ContextMenu' of the rootTreeNode
rootTreeNode.ContextMenu = myRootContextMenu;
I made the assignment.
The context-menues for the child nodes are
ContextMenu myChild1ContextMenu = new ContextMenu();<br />
myChild1ContextMenu.MenuItems.Add("Edit Child 1");<br />
ContextMenu myChild2ContextMenu = new ContextMenu();<br />
myChild2ContextMenu.MenuItems.Add("Edit Child 2");
and assigned in the same way.
Hope this helps a little bit
Regards
Erik
|
|
|
|
|
Db2 is running on as400. We want to have a copy of the data on a windows server with ms sql server.
a. Is there an odbc driver for db2 so we can query db2 from within ms sql server?
b. More in general: how can we copy data from db2 to ms sql server and maybe automate this?
c. what else do we need to know or is there some guide available online.
|
|
|
|
|
There are a few ODBC drivers available for DB2. Google it up! As for copy data between DB2 and SQL Server. Is like a replication system or a one time only process? Do you want to transfer bulk volumes of data or small amounts of it?
I dont know much about the performance aspects of it but if you had ODBC drivers for DB2, couldn't you just query the data from DB2 and insert it into SQL Server and vice versa?
|
|
|
|
|
how can we convert g.DrawImage(image,rect,pixenUnit)
to bitmap Image
|
|
|
|
|
Bitmap bmpMyImage = new Bitmap(image);
- - - --[ i love it when a plan comes together ]-- - - -
|
|
|
|
|
then whether it do tht changes what i have done wen using with drawimage
|
|
|
|
|
s4_sabahatf wrote: then whether it do tht changes what i have done wen using with drawimage
Have another attempt at constructing a readable sentence.
---
b { font-weight: normal; }
|
|
|
|
|
In a smart client application such as TaskVision
http://www.windowsforms.net/TaskVision/[^]
how does one implement single login?
In the current implementation, the application allows any number of logins using the same username and password. Could you please suggest how it can be modified to prevent login if there is a user already logged in with the same username and password? Or better still, to limit the number of simultaneous logins to a predefined number?
Keeping a login count in the database could be a solution, but is there a reliable way to know when a user stops using the program?
Can the constraint be defined in the stored procedure or in the web service(AuthService)?
Thanks.
|
|
|
|
|
i think u can use app.config file to add tag which hold the value of maximum user with same userID and password and if ur storing logged user info in DB then u can
check the user limit at the time of starting ur application.
rahul
|
|
|
|
|
I have two forms f1 and f2.
I have two buttons on f1, from button1 i am invoking f2 using the object of f2 and from button2 i am showing a simple message box.
My problem is, when i open f2 by cliking button1 and click on button2 to show message, when the message box is active i am unable to select f2, its understandable why f1 is not getting selected (message box is modal window), but why f2 is also not selectable?
I used another method to invoke f2, using threading concept, created new thread and invoked f2 in new thread in button1 click event. Now, i am able to select f2 even when message box is active. But when f1 is closed f2 should also get disposed?
Any ideas?
Thanks
Kumar
|
|
|
|
|
I think you should create your own messagebox window (new form) and open that. I cannot think of another approach...
- - - --[ i love it when a plan comes together ]-- - - -
|
|
|
|
|
The solution which i am working on is a huge one, where in i am not allowed to create any new forms of my own. Is there any other way?
Thanks
kumar
|
|
|
|
|
Hi...
In my application , i am creating a project which gives me a dll file i am using that dll in other project. I had added dependency for my application properly. From my windows application project i am starting some threads which are there in dll file. But when i exit my application...only my windows are getting closed(Forms) but my application is running in PC.
Why my application i still running although i am exiting the application...? Is i something with dll...?
Thanks in adavance,
Vinay
|
|
|
|
|
Are u using multi threading or something??
- - - --[ i love it when a plan comes together ]-- - - -
|
|
|
|
|
Hello
please test below code :
<br />
Application.ExitThread();<br />
May be it's usefull !
Regards.
|
|
|
|
|
I am creating application for controlling 8-channel Lightshow through LPT for a small club.
I want lightshow to work by sound input from soundcard. I don't know how can I create a function which would return current output power on the requested frequency(low,mid,high...).
I tried to do this with DirectX.DirectSound, but it seems to me too complicated.
So if anyone have a suggestion, i would be very grateful.;)
Thank you,
Miha
|
|
|
|
|
Hi
I have a DataGridView (C# 2005) which filled from dataset.
Now i want to save the row which user added to last of datagridview.
One of cells type is CheckBox.
When i'm trying to get it's value i see nothing :
<br />
dataRow[4] = dGridView.Rows[e.RowIndex].Cells[4].Value.toString();<br />
I want to see "True" or "False" but i see : "" !?
How can i get the value ?
Thanks for your help.
|
|
|
|
|
Ok
I got my answer myself !
this is the code :
<br />
DataGridViewRow dgRow = dGridView.Rows[e.RowIndex];<br />
dRow[4] = (dgRow.Cells[4].Value.ToString() != "" ? true : false);<br />
Tanx 4 me:->
|
|
|
|