|
No matter how much you read, doing the stuff is the best. Assuming that you have Visual Studio on a machine, you could go to Coding4Fun and look at some of the coding examples. Some of the authors do a very good job explaining what to do and why. It can also give you that boost to go from 'okay...what must I do to write code' to 'okay...what can I code next'.
Over time you'll start to have questions like when do I create a class library, why would I want to overload a method, and stuff like that.
Regardless of what level you are at, if you try something and fail or something goes over your head, we are here to help.
|
|
|
|
|
Hi everybody,
Im creating a c# windows application in framework 2.0,i had created textbox dynamically so that i want to produce tree view structure as the no of textbox i created.I Need only one root node.
The structure is
TextBox
|
|_TextBox1
|_TextBox2
|_TextBox3....
But Im getting the tree structure as
TextBox
|
|_TextBox1
TextBox
|
|_TextBox2
TextBox
|
|_TextBox3
The Code i used is below
int n = 25;
int m = 1;
private void BtnAddControl_Click(object sender, EventArgs e)
{
TextBox txtBox = new TextBox();
txtBox.Text = "TextBox" + m;
txtBox.TabIndex=m;
txtBox.Tag=m;
txtBox.Location = new System.Drawing.Point(10, n);
txtBox.Size = new System.Drawing.Size(70, 20);
txtBox.Name = "TextBox" + m;
txtBox.Click +=new EventHandler(txtBox_Click);
this.Controls.Add(txtBox);
TreeNode root = new TreeNode("TextBox");
root.Nodes.Add(txtBox.Name);
TV.Nodes.Add(root); //TV Treeview name
TV.ExpandAll();
n = n + 20;
m++;
}
How should i accomplish this..
Kanna
|
|
|
|
|
Dotnetkanna wrote: n = n + 20;
m++;
Anyway, try like this...
<code>TreeNode parentNode = new TreeNode();
parentNode.Text = "Whatever";
mainTreeView.Nodes.Add(parentNode);
for(int count = 0; count < 10; count++)
{
parentNode.Nodes.Add(count.ToString());
} </code>
|
|
|
|
|
Hi Kanna.
The reason is because you are creating a new node every time the button is clicked and adding that newly created node to the root level of the Tree itself. I would suggest creating the parent node as a member level variable and then add your new TreeNodes to that parent node rather than to the TreeView.
|
|
|
|
|
If I wanted a service to be discoverable over a LAN would I use UDP multicasting?
Is there a better option?
|
|
|
|
|
|
|
I have created a ActiveX DLL in Visual Basic 6.0 SP5 with one function that returns a String of "Hello World From VB6 DLL". I then register the DLL using RegSvr32 <path and file name of VB6 DLL>. Next, I create a new WebService project in C# using Visual Studio 2005 .NET. In this project, I do an Add Reference, choose the COM tab, and select the DLL I just created in VB6. I add a using directive (using VB6ComTest;) to my Web Service class then proceed to add WebMethod that will call that VB6 function:
[WebMethod]
public string GetTestString()
{
VB6ComTest.MyVBTestClassClass test = new MyVBTestClassClass();
string a = test.HelloWorld();
return a;
}
I'm new to Web Services and using Interop in .NET. I've read that Interop uses interfaces so that may explain why the "Class" is named "MyVBTestClassClass". The intellisense is showing me three (3) items within VB6ComTest and they are: _MyVBTestClass (an interface), MyVBTestClass (an interface), and finally MyVBTestClassClass (a class).
When calling the this GetTestString() WebMethod from Internet Explorer (using the .asmx) or from a console application I have created in the same solution, I get this error every single time without fail:
System.Web.Services.Protocols.SoapException was unhandled
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidCastException: Unable to cast COM object of type 'VB6ComTest.MyVBTestClassClass' to interface type 'VB6ComTest._MyVBTestClass'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{9F789AFC-7C61-4D4F-8EDF-35866D18EEEE}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).\n at VB6ComTest.MyVBTestClassClass.HelloWorld()
I've been battling this for three full work days now and would great appreciate any assistance.
Thank you.
Jason
|
|
|
|
|
Nxorable wrote: Next, I create a new WebService project in C# using Visual Studio 2005 .NET.
Nxorable wrote: I've been battling this for three full work days now and would great appreciate any assistance.
Have you created a C# Winforms project and used the ActiveX control successfully in there?
|
|
|
|
|
Thanks for your reply.
Yes, I have tried directly referencing the DLL in the Console application and it works fine. I have also created a .NET class library that wraps this VB6 DLL and then referenced the the .NET library from the Console app and that work fine too. The moment I try to reference the VB6 DLL from a .NET Web Service, I get this exception.
I've done a lot of research online and in Wrox books with no success. I've verified that ASP.NET and the IUSER account on my box have access to the COM library as well as the HKCR registry keys. I've registered and unregistered the DLL numerous times.
|
|
|
|
|
Well, if you are executing the "exact" same code in the Web Service that works in the console application then obviously the difference is the context. This means some problem like security, access/permissions, registry, etc.
|
|
|
|
|
I have a project write in c# (c/s) need to embed word controler
that is to say, the combox is used word controler instead. so that is free to edit content.
|
|
|
|
|
lockepeak wrote: the combox is used word controler instead
You mean you want a combo box in which you can type and change the value? Thast the default functionality when you add a new combo box.
|
|
|
|
|
I want to embed the word in the windows form.
|
|
|
|
|
lockepeak wrote: I want to embed the word in the windows form.
That still isn't understandable.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
My website
|
|
|
|
|
|
There's an MS Word COM control you could use. It requires that Word be installed on the users machine, and IIRC it's version specific so you'd need to build a separate app for each version of word your clients use. Also it only provides a limited subset of the toolbar and menu options with AFAIK no way to change them. You can find more information via google.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
thank you all of you.lockepeak
|
|
|
|
|
im woking with web forms....I would like to change the backround of web form at run time....how can I achieve that?...
Hi,Im Razana
|
|
|
|
|
Hi, I'm Malcolm
I thought this was gonig to be easy to answer...but unless somebody wants to make me look stupid, it isn't that straight forward. Try this...
Change your <body> tag
<body id="bodytag" bgColor= "#000099" runat="server">
and then in the event handler that is called to change the colour (or on PageLoad) call :
bodytag.Attributes.Add("bgcolor", "#EE33AA");
obviously setting which ever colour you want.
Is there a better / different way anybody? I never change the background color!
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
|
|
|
|
|
|
Hi all,
I am writing an application in which i have a loop to write some outputs over the text box .After i run the application, it works fine as long as i stick to the form and do not click anywhere. As soon as i open any other window to work on and then go back to that output form..It freezes the application and doesnt respond.
The code for instance is as shown below...
<br />
while (true)<br />
{<br />
if(count > 1000)<br />
{<br />
break;<br />
}<br />
<br />
Thread.Sleep(1000)<br />
TextBoxA.Text += "Message" + Environment.NewLine;<br />
TextBoxA.Refresh();<br />
count++;<br />
<br />
}
I guess its something to do with threading...But i am not too sure about it. Pls point me the right direction....
Thanks
SS
|
|
|
|
|
For windows forms in .net 2.0 you can use the BackgroundWorker[^] control. You place it on the form and then put your code into the Do Work event.
If you need to do this in .Net 1.1 or outside of win forms then you can use the Thread Class[^] directly.
To do this you make a new method which takes no parameters and has no return value:
private void TestThread()
{
//DO STUFF
}
Then you create a new thread and start it:
System.Threading.Thread testThread = new System.Threading.Thread(new System.Threading.ThreadStart(this.TestThread));
testThread.Start();
You can also pass things to the thread but I'll leave that for you to read up on
One last thing to note, if you are working with windows forms then you'll need to use the Invoke method on any controls you access across threads.
http://www.codeproject.com/csharp/threadsafeforms.asp[^]
|
|
|
|
|
hey thanks for your reply...
I have added this backgroundWorker and copied the code to backgroundWorker1_DoWork event. Now how can i call this backgroundWorker1_DoWork under btn pressed event to execute the loop...??
Thanks
|
|
|
|
|
Generally, it works like this:
System.ComponentModel.BackgroundWorker bw = new System.ComponentModel.BackgroundWorker();
bw.DoWork +=new System.ComponentModel.DoWorkEventHandler(bw_DoWork);
bw.RunWorkerAsync();
But why not look at the MSDN example?
Standards are great! Everybody should have one!
|
|
|
|