|
Better to use an IntPtr for that sort of thing.
"If a man empties his purse into his head, no man can take it away from him, for an investment in knowledge pays the best interest." -- Joseph E. O'Donnell
Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!
|
|
|
|
|
How to change the text of a text object at runtime in crystal reports for .NET (C#)
I have done one VB.NET and works
myReport = New CrystalReport1
Dim myTextObject As CrystalDecisions.CrystalReports.Engine.TextObject
myTextObject = myReport.Section1.ReportObjects.Item("Text1")
myTextObject.Text = "New Text"
CrystalReportViewer1.ReportSource = myReport
how can i convert this to c#.
DanyBoy
|
|
|
|
|
hi,
Why don't you go for some articles. Lots and lots of good articles are there in codeproject which deals crystel reports. Try that.
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
Thats the answer.
C# .NET
--------
CrystalReport1 myReport = new CrystalReport1();
TextObject myTxtObj;
myTxtObj = (TextObject) myReport.ReportDefinition.ReportObjects["Text1"];
myTxtObj.Text = "testing";
crystalReportViewer1.ReportSource = myReport;
Thanks.;P
DanyBoy
|
|
|
|
|
Hi all,
Ok, I'm new to C# so if I get things wrong then please tell me
My problem is that I have a form with 4 tabs on it. One of the tabs has 2 listboxes on it with some buttons. I need to select items in the left listbox and click a button to move them to the right list box. I have achieved this with using one class (the whole app was written in one class). When I came to change something a few months later I found that with everything in one class it became hard work to read and change. So I decided to re-write it and have a different class for every tab on the form.
This is what I have written.
//from the class named, public class CODLauncher : System.Windows.Forms.Form
public void btnAddRight_Click(object sender, System.EventArgs e)
{
Maps addMap;
addMap = new Maps();
addMap.addMapToRotation();
}
//From another seperate class
public class Maps
{
public void addMapToRotation()
{
CODLauncher moveMapToRotation;
moveMapToRotation = new CODLauncher();
moveMapToRotation.lbMapRotation.Items.Add(moveMapToRotation.lbMapList.SelectedItem);
moveMapToRotation.lbMapList.Items.Remove(moveMapToRotation.lbMapRotation.SelectedItem);
}
All my classes are under the same namespace.
Thanks
|
|
|
|
|
Your objects must be referenced and must be accessible. In order to access a member of one object, you must have a reference to that object. In this case, that object is your Form derivative. In order for your second Form to reference the first, you must either pass it a reference (in the constructor or set a property or call a method), or it may have one already depending on how the second Form was opened. If it was opened from the first Form using ShowDialog(this) , then the second's Form.Owner should reference that first Form , though you'll need to cast it to your form type ((CODLauncher)this.Owner ) in order to access the field defined by CODLauncher (it's not defined on Form ).
Second, your fields lbMapList and lbMapRotation must be accessible. By default, the Visual Studio .NET (VS.NET) designer adds controls as private , meaning only that class can access the fields (that reference your controls). With a control selected, you can right-click and select "Properties", then change the Access property to something like "public" (though exposing controls directly like this isn't a good idea; you should expose the necessary properties like I've done below).
You should read Access Modifiers[^] in the Visual C# language reference for more information about access modifiers.
Here's an example of what I explained above:
using System;
using System.Drawing;
using System.Windows.Forms;
class Parent : Form
{
private TextBox txt;
private Button btn;
static void Main()
{
Application.Run(new Parent());
}
public Parent()
{
this.Text = "Example: Parent Form";
this.txt = new TextBox();
this.txt.Location = new Point(8, 8);
this.btn = new Button();
this.btn.Location = new Point(8, this.txt.Bottom + 8);
this.btn.Text = "Show Child";
this.btn.Click += new EventHandler(this.btn_Click);
this.Controls.Add(this.txt);
this.Controls.Add(this.btn);
}
private void btn_Click(object sender, EventArgs e)
{
using (Child form = new Child())
form.ShowDialog(this);
}
public string ImportantText
{
get { return this.txt.Text; }
}
}
class Child : Form
{
private Label lbl;
public Child()
{
this.Text = "Example: Child Form";
this.lbl = new Label();
this.lbl.Location = new Point(8, 8);
this.Controls.Add(this.lbl);
}
protected override void OnLoad(EventArgs e)
{
this.lbl.Text = ((Parent)this.Owner).ImportantText;
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for the reply.
I'm off to try it, probably take me a week though 
|
|
|
|
|
Hi All,
How can I use a Stored Procedure (Oracle) in C#.
can I do this, or only SQL Server?
Regards,
Kolia
Kolia
|
|
|
|
|
I don't believe that I have heard of Oracle putting this in yet. Sql Server 2005 (Yukon) has this feature. The older versions do not.
Steve Maier, MCSD MCAD
|
|
|
|
|
kolia wrote:
How can I use a Stored Procedure (Oracle) in C#.
The same way you use them in Oracle, actually, and it's supported both by the .NET 1.0 beta ADO.NET driver for Oracle, as well as the one released into .NET 1.1 and included in all future versions of .NET.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Ah... must have read that too fast. I was thinking that it was creating stored procedures that are written in C#. That and its on my mind since I am using Yukon at work now.
Steve Maier, MCSD MCAD
|
|
|
|
|
You use stored procs pretty much the same way as you do with SQL Server, just that the named parameters are identified a little differently (common with different RDBMS's). From the .NET Framework SDK documentation for the OracleCommand.CommandType property:When the CommandType property is set to StoredProcedure, you should set the CommandText property to the full Oracle call syntax. The command then executes this stored procedure when you call one of the Execute methods (for example, ExecuteReader or ExecuteNonQuery).
The Connection, CommandType and CommandText properties cannot be set if the current connection is performing an execute or fetch operation.
The .NET Framework Data Provider for Oracle does not support the question mark (?) placeholder for passing parameters to an SQL statement called by an OracleCommand of CommandType.Text. In this case, named parameters must be used. For example:
SELECT * FROM Customers WHERE CustomerID = :pCustomerID
When using named parameters in an SQL statement or stored procedure, you must precede the parameter name with a colon ( . However, when referring to a named parameter elsewhere in your code (for example, when calling Add), do not precede the named parameter with a colon ( . The .NET Framework Data Provider for Oracle supplies the colon automatically. The same should also be true if you use an Oracle connection string using the System.Data.OleDb namespace classes. To note, the Oracle ADO.NET driver is provided in .NET 1.1 but was only a beta release for .NET 1.0 and, IIRC, is not officially supported (but works). You can use System.Data.OleDb classes for compatibility if you feel you must, but you would be wise to use .NET 1.1 anyway, as many, many performance enhancements and bug fixes were made to the codebase.
So, as an example:
OracleConnection conn = new OracleConnection("...");
OracleCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "myproc(:param1, :param2)";
cmd.Parameters.Add("param1", OracleType.Int32).Value = 1;
cmd.Parameters.Add("param2", OracleType.Char, 40).Value = "CodeProject");
using (conn)
{
conn.Open();
cmd.ExecuteNonQuery();
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I created a datagrid which is populated from an sql query. That works fine, but I also want to capture the datagrid recordcount. Is there an easy way to do this?
|
|
|
|
|
You can either get the count from the datasource that you are binding or you can get the count from the datagrid.items.count after binding the datagrid to the datasource
|
|
|
|
|
hi,
The best way to count no of records in that datagrid is using it's datasource only.
DataTable dt= Datagrid.DataSource as DataTable;
if(dt!=null)
{
int rce_count=dt.Rows.Count;
}
Otherwise you can adopt the way which is explained by other answer thread.;)
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
hi all..
i developing a program that populate a list of items to a listview control and update the list every 2 seconds..the problem is that when i repopulate the items to the listview the horizontal scroll bar return to the top of the listview ...i don't like this to happen...i want the scroll bar to remain at the same position before the listview updated...how can i do this??
thx for your time
|
|
|
|
|
Check into the .TopItem poperty and the .EnsureVisible() method. I think you'll find everything you need in those two members of th eListView .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I was wondering who is using what for zip libraries.
Turns out java.util.zip is a royal piece of junk and doesn't work with Japanese fonts.
Thanks,
Elena
|
|
|
|
|
I found this one easy to use, and reliable:
CSharpZip[^]
Gary
|
|
|
|
|
I am not sure if it supports Japanese fonts, but I agree with Gary, the one from icsharpcode.com is definately a good and easy one to work with.
Steve Maier, MCSD MCAD
|
|
|
|
|
Like Steve, I also agree with Gary. Besides, the java.util.zip.* class in vjslib.dll also has a bug where, IIRC, a ZIP created with it can't be unzipped by "standard" ZIP libraries and applications.
#ziplib (the link Gary gave you) is commonly used by many projects.
I wanted to add, too, that the .NET Framework 2.0 will include ZIP classes (and support for derivative compression streams) in the BCL (base class library), along with many other great features.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hey Elena,
I recently used SharpZipLib and so far it hasn't given me any problems.
Here is the URL:
http://www.icsharpcode.net/OpenSource/SharpZipLib/Default.aspx
I hope it helps.
Cheers,
Suthan
|
|
|
|
|
|
I was previously told by one of the "guru's" of this site that this was not a c# issue. That is not correct because C# is the only language that supports Web Page Comments.
When I use the "Build Comment Web Pages" on the Tools MEnu of VS.NET 2003, the following type of HTML comment is generated at the top of every HTM file
""
I have recently installed Service Pack 2 of Windows XP. Now when the above comment is detetected by IE6, the Internet Zone is considered to be "Restricted" instead of Local Machine. HOW CAN I GET AROUND THIS? Correcting the problem from the XP side is complicated and, as yet, I don't understand it.
Thanks for your help,
Gary Hyslop
|
|
|
|
|
Gary Hyslop at home wrote:
I was previously told by one of the "guru's" of this site that this was not a c# issue. That is not correct because C# is the only language that supports Web Page Comments.
Actually, he was correct. This issue has nothing to do with C#, but everything to do with the security settings in Internet Explorer. I haven't installed SP2 yet, so I can't give you an exact answer. But, the first thing to do is double check the Security settings in IE and try relaxing the security level a bit. If it says High, try lowering it to Medium and see what happens.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|