|
N8url wrote:
It has come in handy for looking into system assemblies on a number of occasions.
Just as long as it doesnt jump into unmanaged code!
top secret xacc-ide 0.0.1
|
|
|
|
|
|
What Control would be a good idea to use if I want to be able to let my control get the keyboard focus? Can I make a usercontrol get the keyboard focus and react to keyboard events?
|
|
|
|
|
UserControl should repond by default to key strokes.
For a custom control, you mite need to enable:
SetStyle(ControlStyles.Selectable, true);
top secret xacc-ide 0.0.1
|
|
|
|
|
Hi all,
I'm just wonder if it is possible to use C# to manipulate data and draw charts in excel. Currently I do know you can do that using Visual Basic / VBA. So for C#? Any idea?
|
|
|
|
|
|
I want to add tabpages to a tab control at runtime. And I should be able to specify those tabpages' names at runtime as well.HOw can I achive this?
samitha
|
|
|
|
|
The same way the designer does it - this isn't magic like Visual Basic (6 and below). Designer code is serialized to source code; taking a look at that would be a first step to understanding.
The TabControl has a collection property - TabPages - that you can add instances of a TabPage to. If you read the .NET Framework SDK for both of these classes, setting a title and adding a page to a tab control should be obvious:
TabPage page = new TabPage("My Caption");
tabControl1.TabPages.Add(page);
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
as you have mentioned I have put my code as follows
//this method is called from the main windows form
public void AddNewTabPage()
{
if(tabReportPages==null)
{
this.InitializeComponent();
}
System.Windows.Forms.TabPage tabPage1 = new System.Windows.Forms.TabPage("test");
//
// tabPage1
//
tabPage1.Location = new System.Drawing.Point(4, 22);
tabPage1.Name = "tabPage1";
tabPage1.Size = new System.Drawing.Size(536, 310);
tabPage1.TabIndex = 0;
this.tabReportPages.TabPages.Add(tabPage1);
//....continues for the othe tab pages
tabPage1.Show();
tabPage1.BringToFront();
tabPage2.Show();
//..continues for the other tab pages
}
but any of the tab pages are not showing..why is that?(the tab control is added to a user control)
samitha
|
|
|
|
|
hi,
i have a tab control with one tabpage and a button in my form. On button click i am executing this much code.
TabPage Newtab=new TabPage("ha ha");
this.tabControl1.TabPages.Add(Newtab);
Is the same you want ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Hi there!
Is there a way to detect the DragDrop event from form to desktop? Most of the articles here are doing the other way
or implementing COM interop (IShellLink...)
I just want my program to detect that the drop operation
was executed in the desktop and not within my form.
Thanks!
|
|
|
|
|
The only way to do that is not something the .NET Framework base class libraries (those installed with the .NET Framework) support. You must use an IStream as a storage medium for drag and drop, something the .NET Framework doesn't support.
I have carried on a very long thread about this here on this forum before. I recommend you search for it (try keywords like IStream or STGMEDIUM and watch for messages from myself and "The Catalyst" - the original poster with the same problem). Reading and understanding the COM interfaces and implementations involved is a must, so go to http://msdn.microsoft.com/library[^] and read in the Platform SDK about the drag and drop shell interfaces.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am trying to adapt the product registration sample code supplied with Inside Visual Studio .Net. The server side asp in the sample reads an XML stream from a request header into an XMLDocument and assigns it to string variables as so:
private void Page_Load(object sender, System.EventArgs e)
{
//Load registration info XML from the request header:
System.IO.StreamReader sr = new System.IO.StreamReader(Request.InputStream);
Response.ContentType = "text/text";
string strXML = sr.ReadLine();
//
//should be able to replace the code below
//with readXML from the input stream directly
//into the DataSet as so:
//
//Registration1 registration = new Registration1();
//registration.ReadXml(sr, XmlReadMode.Auto);
//
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
strXML = System.Web.HttpUtility.HtmlDecode(strXML);
xmlDoc.LoadXml(strXML);
//Unpack the registration info using XPath:
string firstName = xmlDoc.SelectSingleNode("Registration/FirstName").InnerText;
string lastName = xmlDoc.SelectSingleNode("Registration/LastName").InnerText;
string companyName = xmlDoc.SelectSingleNode("Registration/CompanyName").InnerText;
string address = xmlDoc.SelectSingleNode("Registration/Address").InnerText;
string aptSuite = xmlDoc.SelectSingleNode("Registration/AptSuite").InnerText;
string city = xmlDoc.SelectSingleNode("Registration/City").InnerText;
string state = xmlDoc.SelectSingleNode("Registration/State").InnerText;
string zip = xmlDoc.SelectSingleNode("Registration/Zip").InnerText;
string country = xmlDoc.SelectSingleNode("Registration/Country").InnerText;
string phoneAreaCode = xmlDoc.SelectSingleNode("Registration/PhoneAreaCode").InnerText;
string phone = xmlDoc.SelectSingleNode("Registration/Phone").InnerText;
string email = xmlDoc.SelectSingleNode("Registration/EMail").InnerText;
//TODO: Store the registration info for later use...
//
//if ProductRegistrationSQL is the database and
//the cols defined the same as the strings above
//and XML stream read directly into the dataset
//it should be a simple matter to insert the row //into the database as so:
//
//sqlDataAdapter1.Update(registration);
//
Response.Write("Thank-you for registering, "+firstName+"!");
Response.End();
}
Being new to C# and ADO .Net, I'm having a tough time with the four-in-one update concept. I've used the wizard in designer to create the select, update, insert and delete commands and I can see them in the property page for the adapter. But I just don't get how in the code to tell update that what I want to do is insert, not update.
This should be child's play but I'm stumped. What am I missing?
|
|
|
|
|
A DataRow stores change information, such as whether or not it is new, updated, or even deleted. When you use DataAdapter.Update , this information is used to determine which property - SelectCommand , InsertCommand , UpdateCommand , or DeleteCommand - is executed for a particular row. When the DataAdapter.Update is finished updating the data store, AcceptChanges is automatically called on the DataSet (or DataTable , depending on how you called Update ), so there's no need for you to do so.
A DataAdapter is really only helpful when dealing with DataSet s, however. Otherwise, stick to using parameterized queries and IDbCommand implementations (like the SqlCommand or OleDbCommand class) to update the data store using ExecuteNonQuery or something along those lines (depending on what SQL statement you're executing and what you expect returned).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
This app is very simple, data adapter ought to work for it. I've added the following code after the input stream is unpacked and assigned to string variables but it still doesn't update. My test db has one row and it shows up if I preview the data and fill the dataset, so I know the adapter is configured for the sql server ok. The code compiles and runs ok, but update returns 0 as a result and no changes are observed in the database. The one row is unaffected and no new rows are inserted. The response shows the registration first name, so it's unpacked ok.
Registration1 registration = new Registration1();
DataRow workRow = registration.ProductRegistration.NewRow();
workRow["firstName"] = firstName;
workRow["lastName"] = lastName;
workRow["companyName"] = companyName;
workRow["address"] = address;
workRow["aptSuite"] = aptSuite;
workRow["city"] = city;
workRow["state"] = state;
workRow["zip"] = zip;
workRow["country"] = country;
workRow["phoneAreaCode"] = phoneAreaCode;
workRow["phone"] = phone;
workRow["email"] = email;
registration.ProductRegistration.Rows.Add(workRow);
registration.ProductRegistration.AcceptChanges();
registration.GetChanges();
if (!registration.HasErrors)
{
try
{
if (sqlDataAdapter1.Update(registration)>0) Response.Write("Registration Successful. ");
}
catch (System.Exception ex)
{
Response.Write(" Insert Failed. "+ex);
}
}
else
{
Response.Write(" Registration has errors ");
}
//Return a message to the user saying that registration is complete:
Response.Write(" Thank-you for registering, "
+firstName
+"!");
Response.End();
|
|
|
|
|
You should really read the documentation for the AcceptChanges method, although it should be obvious that GetChanges would not work after calling AcceptChanges : you're just removed all change information, so GetChanges would return nothing.
DO NOT call AcceptChanges yourself. As I mentioned in my previous reply, DataAdapter.Update will do this automatically once changes have been committed.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I've been reading documentation for two full days and only your comments made complete sense. While you were posting your reply I was testing that same section of code you mention and I commented out the AcceptChanges and GetChanges. When I do that I get an exception accessing the sql server. I suppose that's progress and I deduce that before commenting out those lines, update was not even trying to access the sql server because there were no changes.
Now I get an sqlException that says the login failed for user 'IBMX40\ASPNET'. IBMX40 is the sql server, but I don't recall ever setting up a user named ASPNET. Need I do that, or can't I simply link the user to the windows log in?
I don't see anything in the properties pages for either the adapter or the connection that allows entry of a password or user. When I issue fill dataset from the data menu while the adapter is selected, I get the test row from the database, so it's accessing sql server for the select.
UPDATE: I went into computer management and gave the ASPNET account (which was already created) administrator privileged and now this code works. Thanks so much for the help!
|
|
|
|
|
JeromeKJerome wrote:
Now I get an sqlException that says the login failed for user 'IBMX40\ASPNET'. IBMX40 is the sql server, but I don't recall ever setting up a user named ASPNET. Need I do that, or can't I simply link the user to the windows log in?
Yes. SQL Server must be told which users are granted access to SQL Server, and then you must grant that user permissions on a particular database object (or for certain server operations).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi
When I want to go for thin client, should I investigate ASP.NET or go with remoting thru http channels?
Does anyone have expirience with this?
Thanks!
Anton
|
|
|
|
|
Anton Dorrestijn wrote:
When I want to go for thin client, should I investigate ASP.NET or go with remoting thru http channels?
It's all relative. .NET Remoting can be used when you can garanttee that both endpoints will be running .NET while this is obviously not required in an ASP.NET application. Does your application require a rich UI? It is all relative to the requirements of the project. I would recommend reading through both the Introduction to ASP.NET[^] and .NET Remoting Overview[^] from the .NET Framework Developer's Guide.
- Nick Parker My Blog | My Articles
|
|
|
|
|
I've started programming in .NET using C#, and a coworker prefers VB.NET. He has created a console application, and I need to turn it into a Windows application and add a Windows form. I would prefer to create the class for this form in C#, but I don't know of a way to do that within his VB.NET project. Must I create a new C# Windows App project, and reference that from within the VB.NET project, or is there a keyword or something to switch from VB.NET to C# for a block of code?
Thanks for any input on this.
Paul
|
|
|
|
|
The easiest thing to do is to take the code that he has written in VB.NET that actually performs the functionality you need, and then make that into a class library. Then create a new C# Windows application and simply use the code from the class library to perform the functionlity you require.
So the steps would be,
1.) Create new Solution
2.) Create new VB project as a class library with the console code (well the bits that actually do the work)
3.) Create new C# project as a windows application and reference the VB class library
4.) Instantiate the class (or classes) of the VB class library from within the C# application and then use the functions as normal.
Hopefully that should sort you out.
Mark.
|
|
|
|
|
Okay, so then there's apparently nothing simple like setting a file that's part of a VB Project to use C# syntax. I wonder why not.
I understand about sharing DLLs; I just thought there'd be a way to code in more than one language in the same project.
Paul
|
|
|
|
|
You can add modules (contains the IL) compiled from different languages into a single assembly, but this does not produce a single file. It produces a single manifest with multiple files, so you really gain nothing. See the documentation for the csc.exe C# command-line compiler (or the vbc.exe for VB.NET) in the .NET Framework SDK, specifically regarding the /target:module and /addmodule switches.
Linking assemblies is your best option. The .NET Framework itself is made up of dozens of assemblies; having your app be comprised of two assemblies is hardly an issue (and allows you to version assemblies independently, so long as you specify the proper version redirection if necessary).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Paul, while what Mark told you was correct, I just wanted to suggest another option however I feel what Mark suggested was the best choice for you. Because both code from a VB.NET and C# project will both compile down to the same MSIL instruction set you have many options. If you are having a problem understanding some of the VB.NET syntax, one thing that can be helpful is to load the assembly into Reflector[^] select the method or class you want to view and change the language in the drop-down to VB.NET.
- Nick Parker My Blog | My Articles
|
|
|
|