|
Hi,
how can i set, get (whatever) data in parameters field on a crystal report. I create a blank report, i also create datasets by code so i can´t drag database fields to the report, just empty fields there!
I want to this by code, so don´t want to change.
Other think is that i can find a field to load pictures (IBlobFieldObject), you have string int date etc, but not any byte [].
(I only get that field if use the design method for dataset and report)
Links, code or advice are welcome
Thanks
nelsonpaixao@yahoo.com.br
trying to help & get help
modified on Thursday, October 9, 2008 8:11 PM
|
|
|
|
|
Hi
Really after some advice if anyone is willing regarding how I can create a class containing arrays or structures. Simple to answer probably but im struggling becuase I come from a procedual C background and havent ever done OO - I just thought it would be interesting to learn - (Trip to the book store on Saturday Morning planned!!!)
Basically what I would like to do is have a class that contains an array. And I want to create an array of these classes to. So I guess something like this -
public class DataStore
{
private static int numberOfStores;
ArrayList myList = new ArrayList()
public DataStore()
{
numberOfStores++;
}
public void ValuesinArray(float ValueToAdd)
{
myList.Add (ValueToAdd);
}
}
public class Application
{
static DataStore[] x = my DataStore[30];
}
Now I get stuck after there! Is anything like this anywhere near correct? How would I add and get stuff from my array (Ideal I want to have several arrays there of for different things but all of the same length)
Are ArrayLists correct? Is there a way to make the array of classes dynamic instead of setting it to a constant of say 30?
Can anyone recommend a resource that details building more complicated objects?
TIA!
David
|
|
|
|
|
davidbrammer wrote:Are ArrayLists correct
I would suppose that would depend on what you are using the array for and how you want to use it. There are many collection classes in .NET.
davidbrammer wrote:array of classes dynamic
You would use a dynamic collection not an array per se. You could use a List for your collection of DataStores. List<datastore> ds = new List<datastore>();
/Edited seems the quoting is not working correctly.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
I have a little macro that I use to auto generate a basic class and collection of that class when I need that sort of functionality.
Sending 'DataStore' to that creates two files DataStore.cs and DataStoreCollection.cs with these contents (namespace and usings ommited!).
public class DataStore
{
public DataStore() { }
}
public class DataStoreCollection : List<DataStore>
{
public event EventHandler CollectionChanged;
private static DataStoreCollection instance;
public static DataStoreCollection GetInstance()
{
if (instance == null)
{
instance = new DataStoreCollection();
instance.Initialize();
}
return instance;
}
private void Initialize()
{
}
public new void Add(DataStore item)
{
base.Add(item);
OnCollectionChanged();
}
public new void Remove(DataStore item)
{
base.Remove(item);
OnCollectionChanged();
}
protected virtual void OnCollectionChanged()
{
if (CollectionChanged != null)
{
try
{
CollectionChanged(this, EventArgs.Empty);
}
catch { }
}
}
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
davidbrammer wrote: Ideal I want to have several arrays there of for different things but all of the same length
It sounds like you are thinking in a non-OO way about how you store data. If I get you right, the reason that the arrays would be the same length is that the items in each array with the same index belong together? Then you should probably use a list of custom objects instead, where you have properties in the object instead of items in separate arrays.
Example:
public class MyCustomObject {
public int Id { get; private set; }
public string Name { get; private set; }
public decimal Price { get; private set; }
public MyCustomObject(int id, string name, decimal price) {
Id = id;
Name = name;
Price = price;
}
public override string ToString() {
return string.Format("{0} (${1:0.##})", Name, Price);
}
}
List<MyCustomObject> myObjects = new List<MyCustomObject>();
myObjects.Add(new MyCustomObject(1, "C# for beginners", 12.50m));
myObjects.Add(new MyCustomObject(2, "VB for veterans", 1.99m));
string name = myObjects[0].Name;
|
|
|
|
|
Thanks all the answers! I think your answer Guffa, is correct, I wasnt thinking in an object orientated fashion.
I think I know how to do this now, I think I need to find a great book on OO and learn it!
Cheers
|
|
|
|
|
Hi
i'm sorry to post here, because i don't found discussion board for sharepoint in codeproject.
my question is that how to create custom calendar type and add it to sharepoint calendar types list (in regional setting page).
the better way to understand what i want to do is that you can see this http://csharptuning.blogspot.com/2008/09/persian-calendar-for-sharepoint-2007.html[^], it have some picture which display persian calendar that exactly i need it, and it does not exist in standard sharepoint calendar types, hence, i must create and add to sharepoint myself, but i don't know how to create it ?
do i must create a web part ?
do i must create a feature ?
do i must create field type/Control ?
and ..... ?
Thanks
|
|
|
|
|
I have two methods on a form. I want to run 2nd method only if 1st method is loaded through the background worker. For instance
Form1
{
Method1();-->loading through the background worker
Method2();-->how can i make sure if background worker is done with Method 1 then run any code after the Method1();
}
|
|
|
|
|
You could use static boolean(?) field in the class to indicate if the work is done. Just remember to use lock when modifying the field.
The need to optimize rises from a bad design
|
|
|
|
|
Events? Create an event, fire it at the end of Method1, and call Method2 in the callback function
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
What was happening is that sometimes the webbrowser1 couldn't load the document and i get the default html error page inside the webbrowser1. I want to load wb2 only if a html document has been fully loaded in webbrowser1 then load it in wb2. Can you please provide me some e.g for be better understanding too
Form1.cs
{
webBrowser1 = new WebBrowser();
webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
path = "c:\a.html"
webBrowser1.Navigate(path);
Controls.Add(webBrowser1);
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (((WebBrowser)sender).ReadyState == WebBrowserReadyState.Complete )
{
//once the document is completely loaded
doc = webBrowser1.Document.DomDocument as mshtml.IHTMLDocument2;
doc.designMode = "On";
if (!webBrowser1.IsBusy)
{
wb2 = new WebBrowser();
wb2.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler (wb2_DocumentCompleted);
wb2.Navigate(path);
}
}
}
|
|
|
|
|
Ouch, apparantly its a pain in the arse to get any error codes from the webbrowser control. The 'best' solution is apparantly this:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.webbrowser.createsink(VS.80).aspx[^]
Set up your browser control like that, and use the NavigateError event. If you get a callback for the event, then the page has not loaded correctly, so you'd want something like:
bool error = false;
wb1_NavigateError()
{
error = true;
}
wb1_docComplete()
{
if(complete && !error)
wb2.Navigate(...)
}
There might be easier ways (there damn well should be) but i couldn't see them.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
I have recently installed Visual Studio 2008 Standard Edition. I tried to add a report to a project and when I drag the ReportViewer to the form, it just puts it at the bottom and does not show it on the form. It also does not show the triangle in the corner to select the report. What am I doing wrong?
|
|
|
|
|
Are you sure that you are using ReportViewer from namespace Microsoft.Reporting.WinForms and not from WebForms?
The need to optimize rises from a bad design
|
|
|
|
|
Yes, the project was originally a VS 2005 Express Project. If I create a new project, I can add a report viewer to a form but it will not let me add a new form to this project and put a report viewer on it.
|
|
|
|
|
Sounds like a problem in references or in project file.
Could you reconstruct the project, meaning create a new project and add all references needed, then add all existing classes.
The need to optimize rises from a bad design
|
|
|
|
|
The project is rather large so i just created a new dll for the report viewer form and referenced it in the old project. That seems to be working. Thanks for your help.
|
|
|
|
|
No problem, your solution should also work fine.
The need to optimize rises from a bad design
|
|
|
|
|
Hi,
I'm having difficulty getting a section of an app.config file to show as encrypted. I run the code and get no errors, but the section does not encrypt. Any help would be appreciated, I've tried other implementations from other posts here with same results:
using System;
using System.Windows.Forms;
using System.Configuration;
namespace AppConfigRedux
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnUnprotect_Click(object sender, EventArgs e)
{
UnProtectSection("connectionStrings");
}
private void btnProtect_Click(object sender, EventArgs e)
{
ProtectSection("connectionStrings", "DataProtectionConfigurationProvider");
}
private void ProtectSection(string sectionName, string provider)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null && !section.SectionInformation.IsProtected)
{
section.SectionInformation.ProtectSection(provider);
config.Save();
}
}
private void UnProtectSection(string sectionName)
{
Configuration config = ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.ExecutablePath);
ConfigurationSection section = config.GetSection(sectionName);
if (section != null && section.SectionInformation.IsProtected)
{
section.SectionInformation.UnprotectSection();
config.Save();
}
}
}
}
|
|
|
|
|
Greetings again!
Can anyone please explain how to use the anonymous constructor with Dictionaries?
eg.:
public static Dictionary<string, UIElement> _controlList = new Dictionary<string, UIElement>()
{
};
Thanks in advance!
|
|
|
|
|
public static Dictionary<string, UIElement> _controlList = new Dictionary<string, UIElement>()
{
{ "Key1", value1 },
{ "Key2", value2 }
};
|
|
|
|
|
|
float a = (float)93.3;
float b = (float)2.3;
float c = a + b; // at this moment c = 95.60001;
Why? I meet this strange behavior not only in C#, but also in Javascript, Actionscript and PHP.
|
|
|
|
|
|
in addition to Dan's link, did you know you can declare a float as a literal by suffixing with an 'f' and save the expense of casting from a double (or int).
float a = 93.3f;
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|