|
If you have your report active in a tab, you should have a Report menu item. You have to use that to add sources to the particular report. Then you should have them as choices when you put components down on the report. If you didn't know already, you have to pass data in as a generic list even if there's only one object that you're working with. And be warned that the editor is NOT NICE when it comes to revising the report, I can't tell you how many times I've had to manually edit the rdlc file to fix something that the automation broke.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Hi,
I've got this piece of code:
Assembly asm = Assembly.LoadFrom(@"C:\Documents and Settings\someDll.dll");
Type type = asm.GetType(someClass);
How can I instantiate a list for the type found above? something like (doesn't work):
System.Collections.Generic.IList<type> list = new System.Collections.Generic.List<type>();
Thanks in advance
|
|
|
|
|
Member 3754905 wrote: How can I instantiate a list for the type found above? something like (doesn't work):
I am not sure I got your question, are you looking to instantiate the type ? Try Activator.CreateInstance()
|
|
|
|
|
No, I've got the type.
I want to make a generic list that contains objects of the type I just found. E.g.:
List<typefound> list = new List<typefound>();
|
|
|
|
|
If the generic type has a default constructor (zero-arg), then all you need do is add a constraint to handle it. Consider this example:
public class CreatableTest<T> where T : new()
{
public static T CreateTestObject()
{
return new T();
}
} The section where T : new() adds the ability to call the default constructor.
|
|
|
|
|
That wont work The type is not known at compile time.
|
|
|
|
|
leppie wrote: That wont work The type is not known at compile time.
Sorry, but it is. Try this sample:
using System;
using System.Collections.Generic;
using System.Text;
namespace MyClass
{
public class Class1
{
public static T Create<T>() where T : new()
{
return new T();
}
}
public class MyTest
{
public MyTest()
{
}
}
} This can be called by:
using System;
using System.Collections.Generic;
using System.Text;
namespace TestHandler
{
class Program
{
static void Main(string[] args)
{
MyClass.MyTest test = MyClass.Class1.Create<MyClass.MyTest>();
if (test != null)
Console.WriteLine("Here I am");
Console.ReadLine();
}
}
} Works fine - it's not useful because other constraints would be useful such as constraining it to a type to get default information.
|
|
|
|
|
Like I said, the type is NOT known at compile time, hence your second snippet will not compile
|
|
|
|
|
Strange - it compiled AND ran when I did it.
|
|
|
|
|
Your code as it is will compile. But in the OP's case, he has no type there yet, so it wont work (you cant just make one there!).
So to wrap it up:
- he loads an assembly
- he gets a type (one that is not known when he compiled the code)
- make a generic List of the runtime type via Type.MakeGenericType, as the type is not known at compile time
|
|
|
|
|
leppie wrote: But in the OP's case, he has no type there yet
Which is why I mentioned that additional constraints would be needed. For instance, he could use IList as a constraint to identify that the item is a list of type T.
|
|
|
|
|
The OP is trying to instantiate a generic class, with only the Type instance for the actual type available. In your example, you were able to pass MyClass as a type parameter, the OP has only typeof(MyClass), which he got through reflection.
|
|
|
|
|
Well spotted - I missed that. That'll teach me not to skim read the question.
|
|
|
|
|
Look at Type.MakeGenericType().
You will have to do something like:
Assembly asm = Assembly.LoadFrom(@"C:\Documents and Settings\someDll.dll");
Type type = asm.GetType(someClass);
Type ltype = typeof(List<> ).MakeGenericType(type);
IList list = Activator.CreateInstance(ltype) as IList;
Note: The bolded types are not generic types, you can use a generic IList if the type or its parent or interfaces are known at compile time.
[update] Or simply use an ArrayList or List<object> [update]
modified on Thursday, June 19, 2008 1:24 PM
|
|
|
|
|
Hello,
I have a lot of asp pages and i have to change to search in this pages to know where a specified method is called.
I have tried more program but no one work.
Do someone know the name of a powerfull software that can a good search.
best regards
dghdfghdfghdfghdgh
|
|
|
|
|
Windows explorer search (using A word or phrase in file) is good, as is Visual Studio.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
I'm using HttpWebRequest & HttpWebResponse classes in my application. I have SSH proxy on my computer which IE or FIREFOX use it to connect to internet. How can I make my application use the same proxy or use the setting in IE? The WebProxy class didn't help me.
Mazy
"This chancy chancy chancy world."
|
|
|
|
|
WebProxy.GetDefaultProxy() although deprecated will return the proxy of IE.
|
|
|
|
|
Hi to all!! Can any body help me abt asterisk ,how to generate call in asteriskwin32 to a local phone in windows xp. How to write call files and entension.conf.
|
|
|
|
|
CP has an article on Asterisk. Search for it.
|
|
|
|
|
Hi,
I want to copy files from one network path to another network path through windows serivce.
I am impersonating the user but it works only for one network path at a time. If I try to impersonate another user the first one becomes invalid.
Is there a way through which we can impersonate two users simulateneously.
I know other way is that I copy file from source network path to local system and then copy it from local system to destination network path i.e impersonating one user at a time but there are other things in my code which will make this too complicated.
I would really appreciate if anybody can help me on this.
Regards,
Rahul Rastogi
|
|
|
|
|
rahulrmetadesi wrote: Is there a way through which we can impersonate two users simulateneously.
I doubt that.
I suggest you tell your 'lazy' admin to create a domain account for you and provide the necessary permissions. It's not your job as a developer to do this.
|
|
|
|
|
Hi Guys,
I solved the problem of the MDI child not maximising, many thanx to all the replies.
What happens now is when an item is selected in a listbox on a dialog form [the dialog is called using ShowDialog() ], it should open another form in an MDI as a child. unfortunately this new child is under the other children.
Question: How do i make it the topmost child to be displayed.
thanx 4 ur anticipated response.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Call the Activate method on the new form.
|
|
|
|
|
i have datagrid contains 4 columns , one of them takes decimal datatype i want to increment this value each time to get the sum
string name;
decimal price, due;
int count;
name = txtSelectedItem.Text;
price =decimal.Parse( lblPrice.Text);
count =int.Parse( txtUnitOrder.Text);
due = decimal.Parse(lblDue.Text);
DGSelectedItems.Rows.Add( name,price,count,due);
decimal sum = due++;
txtSum.Text = sum.ToString();
the value didn`t incremented but replaced
regards in advance
|
|
|
|