|
Have a look at the HttpContext.Current object. You can access your session variables through it, and create some wrapper code around your session variables.
Like this:
using System.Web;
public static class SessionHelper
{
public static string SomeString
{
get { return HttpContext.Current.Session["SomeString"] as string; }
set { HttpContext.Current.Session["SomeString"] = value; }
}
public static int SomeNumber
{
get { return (int)HttpContext.Current.Session["SomeNumber"]; }
set { HttpContext.Current.Session["SomeNumber"] = value; }
}
}
|
|
|
|
|
Why have you posted a question on Web Forms in the Win Forms section?
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello,
In fact i've been misunderstood. I am talking about Winforms not Webforms.
You know that in Webforms you have predfined classes that allows the persistence of variables (or objects) and sharing them between Webforms (Application and Session classes).
What I want is to implement something similar in Winforms, i.e declaring some variable in Form1, and using it in Form2 .. FormN..
I guess that the first answer of gajatko would help.
Thank you.
|
|
|
|
|
You can use public variables in this manner,
public static class Global
{
public static string fromForm;
}
you can assign a value to fromForm variable in form1 and you can use it in form2
another way is declare public variable in form2
and pass a value to form2 as a parameter when you call form2 from form1
-- modified at 2:01 Thursday 27th September, 2007
|
|
|
|
|
hi everybody, how u doin ?
i have a problem, i created many projects seperatly and i want to combine them in one with a main form with buttons that links to them.
i'm adding the projects using File->Add->Existing Project, and then i'm adding a reference to them, but still i can't access the forms.
any one can help me out ?
thanks in advance.
Know thyself
|
|
|
|
|
I'm just trying to do this and I have no problems. Remember that a class from other projects may be in an another namespaces. Also, if a name conflict occurs then the class from the main assembly are used.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
the thing is that the projects are small and there are no classes, only functions and modules inside the forms' code. and each application has its own functionalities, datasets and reports, nothing that big. so i just want to link from a main form (also created seperatly) to all of the others.
Know thyself
|
|
|
|
|
Which programming language do you use? All .NET forms are classes inheriting from the System.Windows.Forms.Form .
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
the forms are written using vb.net
to be specific, i wrote another project and i added the projects blablabla...
i want to be able to do the following while i'm in the new project:
Project.Form.show()
can i do this just by adding the project and adding a reference to it?
Know thyself
|
|
|
|
|
Yes you can! I just did it again and added a button to a form:
private void button1_Click(object sender, EventArgs e)
{
WindowsApplication1.Form1 frm = new WindowsApplication1.Form1();
frm.Show();
}
which would look in VB.NET like this:
Private Sub button1_Click(sender as object, e as EventArgs) handles button1.click
frm as new WindowsApplication1.Form1
frm.Show()
End Sub
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Hi,
Iam using Windows based DatagridView..So i want to display the Child View..
and iam adding the TextLinkColumn..So just if i click the TextLinkColumn and displaying the related records in Child DataGridView..
Here i done the coding for displaying child dataGridview..So iam geting error in this Coding part...
already i've done the RelationShip to dataBase Tables
Error is:"Child list for field APPLICATION_DETAILS cannot be created."
here...Declare dtTable- DataTable
private void LocationView(int applicationID)
{
this.Cursor= Cursors.WaitCursor;
APPLICATION locationForm=new APPLICATION();
CurrencyManager cm = ((CurrencyManager)this.BindingContext[dtTable, "APPLICATION_DETAILS.APPLICATION_DETAILSAPPLICATION"]);
IBindingListView list=(IBindingListView)cm.List;
locationForm.ShowDialog(applicationID, this, list);
this.Cursor=Cursors.Default;
}
Pls tel me..now critical situation..
Pls need help..
Somu
|
|
|
|
|
Please can you help me out in this.....
I am having trouble in changing my checkbox backcolor into red when CheckedState is checked, yellow when it's undeterminate and unchecked turns to normal color.
CheckBox Property:
1.ThreeState = true //unchecked,undeterminate,checked
2.CheckedState = unchecked; //unchecked,undeterminate,checked
3.BackColor = System.Control; //normal color
code for the first CheckedState..
checkBoxName.checked = true;
checkBoxName.BackColor = Color.Red;
|
|
|
|
|
All you have to do is handle the CheckStateChanged event of the CheckBox and check the value of the CheckBox's CheckState property. Set the BackColor accordingly.
|
|
|
|
|
I'm trying to add a StringCollection to the resources of my application.
In the VS Resource Editor there is a section called "Other" and accourding to the MSDN article it is possible to add any type that supports serialization, but I'm unable to do it. The grid is inactive.
Does anybody know a solution to the problem?
|
|
|
|
|
Hi,
Please try the following steps toadd a string resource.
1) With a project selected in Solution Explorer, on the Project menu, click Properties.
2) Click the Resources tab. On the Resource Designer toolbar, point to the resource view drop-down, click the arrow, and make sure it is set to Strings (which is the default). A settings grid will appear, displaying the strings maintained by that instance of the Resource Designer.
3) Click on the Name column of the last row in the grid, which is marked with an asterisk (*).
4) In the Name column, enter a name for the string.
5) In the Value column, enter the string to be used as a resource.
6) Optionally, enter a comment in the Comment column.
Hope this helps .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
I am using Windows DataGridView....
How to Display the Parent With Child View
iam using TextLinkColumn..So if i Click the TextLinkColumn and displaying the Child View from another Table.
So Pls any example...
pls tel me..
Regards
Somu
|
|
|
|
|
internal Lybra.Forms.Controls.GradientPanelXP pnlHeader;
i declared like this
but i got error.
the type or namespace name"lybra"couldnot be found...
what should i do?
|
|
|
|
|
the compiler is saying it doesn't know what the Lybra namespace is.. make sure that you have a reference added to your project to the DLL you are trying to use. If you don't have the DLL, or don't know what I mean, then you might want to talk to the creator of the control you are trying to use.
|
|
|
|
|
You have to add a reference to the lybra namespace, as the other poster said.
"I really like comments where I don't have to answer stupid questions" - stfx
|
|
|
|
|
Actually.i want to display the Child Datagrid form Access Database table
iam using the coding:
CurrencyManager cm = ((CurrencyManager)this.BindingContext [dtTmp,"APPLICATION_DETAILS.APPLICATION_DETAILSAPPLICATION"]);
Iam getting this Error!!!!
"Child list for field APPLICATION_DETAILS cannot be created."
Pls tell me
somasundaram
|
|
|
|
|
Quit reposting the same question. It doesn't make anyone answer your question any faster.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi everyone,
For a windows application that we are developing, there is a datagridview that holds the list of users in the system.... The datagridview should support sorting and also , the datgridview will be updated whenever a user is added to the system.
In such a scenario, which is the better option -
1) Using a BindingList as the Datasource to the gridview , update the bindinglist and call the ResetBindings to update the grid
OR
2) Use the DataGridView.Rows.Add / insert method to add rows
|
|
|
|
|
If your application is built using DataBinding then you have to use your first approach: always modify the data and reflect them by the UI,otherwise you will possibly get some nasty binding problems.
The second approach is useful if you use a model-view-presenter (or similar) model to fill the data into the DataGridView in the View.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
The issue is that we are get frequent updates to the GridView , as far as i know , the ResetBindings will reread all the items in the list and refresh their displayed values. Will that be a performance issue
|
|
|
|
|
so here quick and dirt code to illustrate problem i have.
PROBLEM: when you have controls more that few, it tooks a lot of time for redraw them all.
this redrawing it visible and horrible.
even if you using custom control with (i think) faster repaint, it nosense...
so, maybe there's some styles or properties or something to make it faster?
or some other techniques?
--
yours,
mrRobot.
-- modified at 6:29 Monday 17th September, 2007
as i found here:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2044742&SiteID=1
there is no good solution for this problem. it possible to freeze window/control for repainting, but no speedup at all. sad.
using System;
using System.Drawing;
using System.Windows.Forms;
namespace custCompTest2
{
public class custCompTest2 : Form
{
public custCompTest2()
{
this.Name = "custCompTest2";
this.Text = "custCompTest2";
this.ClientSize = new System.Drawing.Size(400, 400);
for(int n=0; n<800; n++)
this.Controls.Add( (new tgC()) );
}
protected override void OnSizeChanged(EventArgs e)
{
this.SuspendLayout();
int x=0, y=0, w=Width/40, h=Height/21;
foreach (Control c1 in Controls)
{
c1.Location = new Point(x,y);
c1.Size = new Size(w,h);
if(x+w*2+1<Width) { x+=w; } else { x=0;y+=h; }
}
this.ResumeLayout(false);
}
protected override void OnLoad(EventArgs e)
{
this.OnSizeChanged(e);
}
[STAThread]
static void Main()
{
Application.Run(new custCompTest2());
}
}
public class tgC : Control
{
public tgC()
{
this.SetStyle(
ControlStyles.UserPaint |
ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw
, true);
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawRectangle(Pens.Black, 1,1, Width-2, Height-2);
}
}
}
|
|
|
|