|
Hey all,
I have DataRelation object between 2 tables & 2 DataGrids.
for some reasons, I delete the relation, activate an operation on the tables & then create the relation back. here is some code:
//before the operation starts:
Ds.Relations.Clear();
Ds.Tables["Cust2"].Constraints.Clear();
//after the operation
DataColumn dc1 = Ds.Tables["Cust1"].Columns["Id"];
DataColumn dc2 = Ds.Tables["Cust2"].Columns["Id"];
DataRelation Dr = New DataRelation("cust1to2", dc1, dc2);
Ds.Relations.Add(Dr);
everything is ok until now.
but when I tried to connect the tables to the datagrids:
DtGrd1.SetDataBinding(Ds, "Cust1");
DtGrd2.SetDataBinding(Ds, "Cust1.cust1to2");
I get the exception:
"Cannot have a relationship between tables in different DataSets"
does anyone know what is going on??
thanks
RoyRose
|
|
|
|
|
How can I maintain a strongly typed collection over a web service... when I try to access an item it turns out to be a generic object, and the type is generalized as an System.Object without its attributes/methods (even the ones specified as webmethod)
Its not allowing me to access any of the methods.
-Steven Hicks
CPACodeProjectAddict
-- modified at 2:16 Sunday 20th November, 2005
|
|
|
|
|
I am trying to recieve a couple of words out of an HTML web page. I have received the information and stored them in a string. How do I find and get everything after these words "Name:"?
Thanks for the help.
|
|
|
|
|
Name: (.*)
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I have some CheckBoxes that I create at runtime and I need to iterate throught them. They are all named "TextBoxAuthorName1" "TextBoxAuthorName2" etc...
How can itterate through them in a for loop?
I think this might be called reflection, but i'm not sure..
i want to get their names, but i'm confused about how to do it...
|
|
|
|
|
Or is there a way to get all the controls on the webform and them filter out the TextBoxes and then filter them about again by their name?
/\ |_ E X E GG
|
|
|
|
|
An easy way to itinerate trough your TextBoxes without reflection is to get each contol you have in the collection that has the TextBoxes an check if it's name is the one you desire :
public void CheckContols() {
foreach(Control c in this.Controls) {
if(c.Name.StartsWith("TextBoxAuthorName")) {
}
}
}
Using reflection to do what you want is kind of like scratching your left ear with your right hand.
I hope you understand...because is a rough world out there...
|
|
|
|
|
Using reflection to do what you want is kind of like scratching your left ear with your right hand.
But why enumerate all controls? This would shorten the whole process a bit:
foreach(TextBox b in Contols) ...
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Try for yourself the method you described and you will notice an error message that sounds something like "Specified cast is not valid.".
A foreach can be used to itinerate through an Collection's items.
A collection can have items of differnt types (eg. you Controls collection : can have a Label , two Buttons an a bunch of TextBoxes ). When the foreach reaches a Button an tries to cast it to a TextBox it will cause an exception.
I hope you understand...because is a rough world out there...
|
|
|
|
|
This should work on a web app right?
/\ |_ E X E GG
|
|
|
|
|
when i do this on an aspx page all it returns is Form1? do know how i can get the controls?
/\ |_ E X E GG
|
|
|
|
|
Proably you walk through the controls of the aspx page. The ideea was to walk through the parent control of your TextBoxes. I assume that the parent control is Form1, than, in that case, my exemple above is almost the same, instead of this.Controls use Form1.Controls .
I hope you understand...because is a rough world out there...
|
|
|
|
|
hi
I have a Form form1 that has a non-static public method called func1()
form1 has a custom control object called CU1
how can i call form1.func1() from CU1??
|
|
|
|
|
If CU1 is a custom object that you have designed yourself you could probably use the following example
<code>
namespace TestSpace
{
public delegate void MyFunc1Handler();
public class CU
{
public event MyFunc1Handler OnFunc1Handler;
public CU()
{
}
private void someInternalFunction()
{
OnFunc1();
}
protected virtual void OnFunc1( void)
{
if( OnFunc1Handler != null )
OnFunc1Handler();
}
}
}
</code>
and in your owener class (in your case the Form1 class) just create a function that you will assign to be the handler of the event of type MyFunc1Handler. Basically in the example above the function will have the following signature: void fnName(void);
<code>
public Class Form1: System.Windows.Forms.Form
{
private TestSpace.CU CU1;
public Form1
{
InitializeComponent();
this.CU1 += new TestSpace.MyFuncHandler1(AFunc1Handler);
}
private void AFunc1Handler(void)
{
}
}
</code>
Hope this helps
|
|
|
|
|
I just started taking a look at C# yesterday, it's pretty interesting. It's like what Java would have become if it wanted to be like C/C++.
First question: I have a small class with a string and a long. I want to create an object using that class and add it to a collection and to a ListBox. That part works, but when I add the object to the list box, instead of saying what it should, instead it says "project1.Form1+MyObject". I'm pretty sure it doesn't know know how to represent that object as a string so it uses that string as a default. I can also type "MessageBox.Show ("" + obj);" and it tells me the same thing. My problem is I don't know how to add the functionality to my C# class that when asked for a String that I can give it the right information.
I've looked around this message board and on all the C# articles but I can't find anything about it.
|
|
|
|
|
Sound like you need to override the System.Object.ToString() method.
Take a look at the .Net SDK documentation for hints on handling this.
Hey don't worry, I can handle it. I took something. I can see things no one else can see. Why are you dressed like that?
- Jack Burton
|
|
|
|
|
That sounds like just what I was looking for. I'll check that out, thanks a lot.
|
|
|
|
|
Hi All
I writing some application in C#.
In my application i have a lot of Const variable , and for this reason i add class with the name "Constant" to my application.
In this class i add this lines
public class Constant
{
public const long A = 0x1;
public const long B = 0x2;
.
.
.
.
}
Now - i want to add to each class in my application this class- i mean that i want for each class to use this Constant variables.
My question : is there some way to do it with out create in each class that use Constant class without use the Constant class constructor ?
I think i can use "nameSpace" but i dont know how to do it without use the Constant class constructor.
Some one can help me?
[in C++ i add the header file to some file (in MFC) that each *.cpp file have it and in this way each *.cpp file know about each #define that i add to the file.]
|
|
|
|
|
Constant values can be used without an instance to the class :
<br />
namespace ConstantsNamespace {<br />
public class Constant<br />
{<br />
public const long A = 0x1; <br />
public const long B = 0x2; <br />
.<br />
.<br />
}<br />
}<br />
<br />
namespace myNamespace {<br />
public class TestClass {<br />
public TestClass() {<br />
Console.WriteLine(ConstantsNamespace.Constant.A);<br />
}<br />
}<br />
}<br />
I hope you understand...because is a rough world out there...
|
|
|
|
|
For that to work, the variables would have to be public static const long A = 0x1; ...etc.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." - Jörgen Sigvardsson
|
|
|
|
|
A const cannot be marked as static .
Try it for yourself if you do not belive me.
I hope you understand...because is a rough world out there...
|
|
|
|
|
That's right. My bad. Sorry about that.
What he'll want to use then is something like:
public static readonly myVariable = 0x1;
Otherwise he'll have to new up an instance of the Constants class every time he wants to use one of them.
Picture a huge catholic cathedral. In it there's many people, including a gregorian monk choir. You know, those who sing beautifully. Then they start singing, in latin, as they always do: "Ad hominem..." - Jörgen Sigvardsson
|
|
|
|
|
This is not correct. Fields declared with the const keyword are implicitely static. Thus you can use them without having an instance.
|
|
|
|
|
Hi,
I got a problem i used ShockWave Flash Object that is available in visual studio 2005, where i make a project by C# and load .swf files in that control and it provides my by all actions that are taken on a flash movie,i.e. when action like click occurs on a thing in the movie i will e notified in c#.
All that was great but when i move the project to another machine i get a surprising thing, the movie is displayed but actions not give me any notification.
note: **the second machine that i tried to work my project on it was have a flash media player setuped on it. And when i downloaded the macromedia flash professional program and installed it the program worked again but i cant download on every client that program so i need a solution.
please any boody help me, i have an un-believable bug.
Regards,
22DoorsDown <me4webby@yahoo.com>
|
|
|
|
|
When I`m running an application, I would like to run another application and receive handler to that process (to send him messages). How to do that in C#?
thank you for any help
|
|
|
|