|
Well your code looks fine, so the only thing I can think of is that LoadReport is being called before you set the session ID - that is, it is being called from the constructor of form 2. If you are calling LoadReport from the constructor of form 2, then SessionId will not have the proper value in it, because you are setting its value only after the constructor is finished.
So the main question is: when are you calling <ocde>LoadReport in Form2?
If you are calling it in the constructor of Form2, then I recommend instead that you make an event handler for the Form.Load event and in that, call the function LoadReport .
Let me know if that gets you anywhere.
Sincerely,
Alexander Wiseman
|
|
|
|
|
Thank you again. I am calling it from the constructor and with that said, I am sorry man but how do I create and event handler? Please give an example?
Thanks again
sasa
-- modified at 22:33 Wednesday 28th June, 2006
|
|
|
|
|
Hi Alexander;
I created an event handler and got it to work. Thank you man, I really really appreciate your help. You are my guru.
sasa
|
|
|
|
|
Excellent! I'm glad it worked out for you.
Sincerely,
Alexander Wiseman
|
|
|
|
|
You didn't do what Martin suggested and so it fails because in this:
SASA_1 wrote: Form 2
When I try to output SessionId it shows 0
string test=SessionId.ToString();
MessageBox.Show(this,test);
You're assuming that "SessionID" from Form 1 is global and it's not.
What you're not entirely clear on is the architecture on how Form 1 and Form 2 are actually created. Do they both get created in Form 0 or does Form 2 get spawned from Form 1? How are they created?
That will dictate how you pass the data between the two. Generally the easiest way is through the use of a public variable created at a level that makes it global.
Mike Poz
|
|
|
|
|
Sorry to meddle!
But why don't you use the events?
Try this:
1)Create an EventArgs class.
2)A delegate.
3)An event of type your delegate.
4)Raise the event and pass the SessionId as the EventArgs Property.
Read this article and contact me if you had any problem.
EventArgs Class
Sojaner!
|
|
|
|
|
hi guys
how should I load a database into a Dataset object.
when loading from a DataAdapter i should use an SQL command. what if when i want to load all tabless and reltions and ... in a Dataset?
i want to make a program to load all sort of databases (even without knowing the name of the tables)
thx guys
|
|
|
|
|
Try to see this:
http://msdn2.microsoft.com/en-us/library/bh8kx08z.aspx
|
|
|
|
|
Sorry for posting this again. What I want to do is save the state of my windows form. What I heard so far XMLSerializing is a good way to go. If I got it right: Due to containing interfaces many classes can't be serialized. So the Form itself can't be serialized. So I need to serialize elements of this form. These are Controls (Labels and UserControls). If the above applies, I see no way doing so, except serializing lets say the Text of a Label and then later deserialize the string, create a new Label and set the Text to the deserialized string, which is a really bad situation. Is there any better way?
Thanks for helping me out.
|
|
|
|
|
You don't need to recreate the controls dynamically. Just catalog the information you need to save, organize it into some XML format, then use XSD.exe or something like Skeleton Crew[^] to generate an XML serializable model.
Then on form load, read the XML file and use the resulting model to update the controls affected by your information, and on form closing fill a model with your information and serialize it out to the XML file.
You can restrict your data to the text in text fields, or the form's size, or whatever you want to persist. Keep it simple.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Greetings!
I'm having a spot of trouble involving the saving and restoring of UserControl states on a form and was wondering if somebody could help me figure it out.
Here's some background:
1. I have 11 instances of a UserControl on a form.
2. The UserControl has, among others, two boolean properties "Mute" and "Solo".
3. Everytime the Solo property of a control goes "true", all the OTHER controls are disabled and only the "soloed" control is active. The Mute property of any control other than the soloed control may not be changed while the solo is active.
And here's the problem:
1. One or more UserControls may be muted at the time that a particular UserControl is soloed.
2. Upon "unsoloing" the soloed control, the previously muted controls should remain muted.
Here's my approach so far and some pseudocode:
1. I have two events - a SoloHandler and a MuteHandler.
2. I'm assuming that the "state memory" code needs to go into the solo handler.
3. Pseudocode
<br />
if (sender.Solo)<br />
{<br />
<br />
}<br />
else <br />
{<br />
}<br />
AND FINALLY... Here's my question to you!
How do you suggest I go about saving the state?
Should I use an array and store references to the Controls in the collection using the GetChildIndex property?
Is there another way that is more elegant and is easier to code?
Thanks!
|
|
|
|
|
I hope I got everything!
Here is what I would do:
//Create an additional boolean Property "BlockMute" in your class "YoureUserControlClass"
public bool BlockMute
{
get
{
return _blockmute;
}
set
{
if(value!=_blockmute)
{
_blockmute = value;
}
}
}
public bool Mute
{
get
{
return _mute;
}
set
{
if(value!=_mute)
{
if(Blockmute== false)
{
_mute = value;
}
}
}
}
//SoloHandler
{
YoureUserControlClass actc = sender as YoureUserControlClass;
foreach(object o in this.Controls)
{
if(o is YoureUserControlClass)
{
YoureUserControlClass c = o as YoureUserControlClass;
if(actc.Solo == true)
{
if(o != sender)
{
c.Enabled = false;
c.Solo = false;
c.BlockMute =true;
}
else
{
c.Enabled = true;
c.BlockMute = false;
}
}
else
{
c.Enabled = false;
c.BlockMute = false;
}
}
}
}
All the best,
Martin
-- modified at 15:59 Wednesday 28th June, 2006
|
|
|
|
|
I'm trying to find a way to grab a given rows cell information, for now just the primary key, and store it in a variable to use somewhere else. If I use listbox's I can simply use .selectedValue() and it gives me exactly what I need, but in this case, I'm needing to do it with a datagridview and this attribute doesn't exist. Thanks!
|
|
|
|
|
PyroManiak wrote: I'm trying to find a way to grab a given rows cell information, for now just the primary key, and store it in a variable to use somewhere else.
If your DataGridView is populated through a DataSource, then the following code snippet might help you.
stringVariable = dataGridView.Rows[index].Cells[index].Value.toString();
Here index could be an integer value or variable holding a value: and is zero (0) based. Alternatively you can use Column name as Cells index, like:
stringVariable = dataGridView.Rows[index].Cells["ColumnName"].Value.toString();
Also you can get the value from the selected or Current row, like this:
stringVariable = dataGridView.CurrentRow.Cells[index].Value.toString();
Using the same technique you cann't get value from an unbound datagridview
Hope this would solve your problem.
Best of Luck.
_____________________________
Success is not something to wait for, its something to work for.
|
|
|
|
|
stringVariable = dataGridView.CurrentRow.Cells[index].Value.toString();
That worked for my purposes just great!
Thanks a bunch!
|
|
|
|
|
Hey, I need a regular expression that matchs to the following elements:
* the input string must have # in the start of it.
* the input string needs to be longer than 1.
eg.: #b <- ok; # <- not ok; b <- not ok; ## <- ok...
I just don't know how to use Regular expressions...
So thanks alot ^^.
NaNg.
|
|
|
|
|
This one works for me:
^\#[^\r\n]+.*
I had to add the [^\r\n]+ , because Expresso matches some character that simply wasn't after the dash, even when I appended a $ at the end
Or, without Regex:
string foo = "#asdf";
if(foo.StartsWith("#") && foo.Length>1)
{
}
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
@"^#.+"
... works for me (in code ... I don't know about Expresso). Remember, "*" specifies zero or more. The "." should not match \r\n unless you are using the RegexOptions.Singleline modifer.
- Bitwise
|
|
|
|
|
Hi there!
I have an application with 2 projects.
First project, I have a mdi form which is a Windows application i.e. I can't use it as a reference. This mdi form is the only item in my 1st project. In my mdi form I have a status bar.
Second project, this is a class library with Windows form, how do I access the status bar in my mdi form from my Windows form when I can't reference it?
Please help
sasa
|
|
|
|
|
You don't. Whatever your writing that is trying to update the statusbar should, instead, be exposing an event that the MDI form can subscribe to. That event should send the message as a String, or whatever else you want really, and the subscriber, namely the MDI Form, should update it's own status bar.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hello i need to convert a control.CreateGraphics() for my app. VS2005 gave me a runtime error saying that it's not supported for Compact framework.
Is there anyway to bypass that?
Donkaiser
|
|
|
|
|
Oh I want to create graphics components on a panel.
Donkaiser
|
|
|
|
|
As far as I can see you should be able to create a Graphics object using the Handle of the control.
---
b { font-weight: normal; }
|
|
|
|
|
Unfortunatelly you can't.. When you make something like this :
Graphics g = Graphics.FromHdc(panel1.Handle);
It throws an exception "ArgumentException - Value does not fall within the expected range". And that's all. I have the same problem like donkaiser. I'd like to draw something on a tabControl or a panel and I don't know how.
|
|
|
|
|
I used the paint event of the tab. but my problem is that i need to update the drawing color according to my input data. how to raise the paint event again is still a mystery. I bypassed the problem with panel.invalidate() but now i have flickering problems.
Donkaiser
|
|
|
|