|
I am in the process of designing a generic 'record maintenance' toolbar class containing the 'standard' add/edit/delete/save/cancel buttons. I notice that the VS toolbox already has a bindingnavigator control which already has some of the functionality that I require (although I don't require the navigation buttons).
Which control should I go for? As far as I can see the bindingnavigator is just a glorified toolbar bound directly to a datasource, but I may be missing something.
Can I subclass a toolbar/bindingnavigator visually or does it have to be done in code? I am using C# with VS2005 express.
TIA
Alan
|
|
|
|
|
aharrisreid wrote: I am in the process of designing a generic 'record maintenance' toolbar class containing the 'standard' add/edit/delete/save/cancel buttons. I notice that the VS toolbox already has a bindingnavigator control which already has some of the functionality that I require (although I don't require the navigation buttons).
Which control should I go for? As far as I can see the bindingnavigator is just a glorified toolbar bound directly to a datasource, but I may be missing something.
Can I subclass a toolbar/bindingnavigator visually or does it have to be done in code? I am using C# with VS2005 express.
You can just use Windows Forms' BindingSource and create a decent ToolStrip (previously known as ToolBar in .NET 1.x), with your own buttons with custom actions.
Any data binding applications in Windows Forms can do navigating by just using BindingSource with a valid DataSource such as DataSet or DataTable.
Start from this:
http://msdn2.microsoft.com/en-us/library/ef2xyb33.aspx[^]
Eriawan
|
|
|
|
|
Hi kuyak2000, thanks for the reply.
You can just use Windows Forms' BindingSource and create a decent ToolStrip (previously known as ToolBar in .NET 1.x), with your own buttons with custom actions.
The problem with the BindingSource is that I don't require the navigation buttons, which only leaves the add and delete buttons, so I would have to add my own edit/save/cancel buttons. It might make more sense for me to create my own customised toolstrip.
Regards,
Alan
|
|
|
|
|
aharrisreid wrote: The problem with the BindingSource is that I don't require the navigation buttons, which only leaves the add and delete buttons, so I would have to add my own edit/save/cancel buttons. It might make more sense for me to create my own customised toolstrip.
Using VS 2005 IDE, you can just add BindingSource by dropping from toolbox, and then start to create your own ToolStrip with your own data manipulation buttons. Dropping BindingSource doesn't create new BindingNavigator on your Form.
regards,
Eriawan
|
|
|
|
|
Hi Eriawan, thanks for the reply.
kuyak2000 wrote: Using VS 2005 IDE, you can just add BindingSource by dropping from toolbox, and then start to create your own ToolStrip with your own data manipulation buttons. Dropping BindingSource doesn't create new BindingNavigator on your Form.
I think I understand what you are saying, but how do I use toolstrip buttons in conjunction with the bindingsource to achieve the required action? For example, say I have a 'Save' button on the strip. What sort of code would it have called from the Click method which saves data back to the database? Can you point me to any examples?
Any help would be appreciated.
Alan
|
|
|
|
|
It's quite easy.
- First you have to validate the form using Form.Validate() method,
- End the edit of bindingsource used using BindingSource.EndEdit() method.
- Save the datasource. If you're using TableAdapter, just use Update() method
Good luck!
best regards,
Eriawan
|
|
|
|
|
Hi Eriawan,
That was easier than I thought it would be. I'll try it out asap..
Thanks,
Alan
|
|
|
|
|
I have a DataGridView on a windows form. If a user clicks on a cell, a property gets the current row and then populates data in another form. When a cell is highlighted, if a user double clicks on the columnheaders the modal form loads with the data from the highlighted row. I want to stop users from being able to double click on the column headers. Does anyone have any suggestions on how I could do this?
Thanks,
Taylor
|
|
|
|
|
Your question is not very clear to me. If you want to do something when you double click on a cell (and avoid doing anything if the user double clik on the header)
you can do something like this,
private void gvList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
int miHitRow = Convert.ToInt32(e.RowIndex);
if (miHitRow < 0)
return;
//your code
}
|
|
|
|
|
Hey,
I need to share variables among forms in the Web session (or application) manner. I used to have some code - which I don't have now- that implements the singleton design pattern and allows adding and retrieving objetcs this way :
Application["MyObject"] = object;
Can you help?
Thanks.
|
|
|
|
|
I would use a static class with a static member with an indexer:
public static class SC
{
private static SettingsClass settings = new SettingsClass();
public static SettingsClass Application
{
get { return settings; }
}
public class SettingsClass
{
Dictionary<string, object> settings = new Dictionary<string,object>();
public object this[string id]
{
get
{
return settings[id];
}
set
{
if (!settings.ContainsKey(id))
settings.Add(id, value);
else
settings[id] = value;
}
}
}
}
add use it this way:
SC.Application["key"] = someObject;
Hope it helps anyhow.
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.
|
|
|
|
|
Hello,
Thanks gajatko for your help.
Your code uses generics and SettingsClass that are not available in C# 1.1. How can I rewrite it to make it work in VS2003?
Thanks.
-- modified at 10:25 Monday 24th September, 2007
|
|
|
|
|
Implement System.Collections.DictionaryBase.
public static class SC
{
private static SettingsClass settings = new SettingsClass();
public static SettingsClass Application
{
get { return settings; }
}
public class SettingsClass
{
StringObjectDictionary settings = new StringObjectDictionary();
public object this[string id]
{
get
{
return settings[id];
}
set
{
if (!settings.ContainsKey(id))
settings.Add(id, value);
else
settings[id] = value;
}
}
}
}
class StringObjectDictionary : System.Collections.DictionaryBase
{
public StringObjectDictionary() : base()
{
}
public void Add(string key, object value)
{
base.Dictionary.Add(key, value);
}
public object this[string key]
{
get { return base.Dictionary[key]; }
set { base.Dictionary[key] = value; }
}
public bool ContainsKey(string key)
{
return base.Dictionary.Contains(key);
}
}
Edit: The alternative is use of environment variables (Environment.SetEnvironmentVariable ). They also are session-like.
-- modified at 11:16 Monday 24th September, 2007
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.
|
|
|
|
|
You can also use cookies, whose default expiration time is exactly one session.
Request.Cookies.Add(...);
Request.Cookies[id]...
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.
|
|
|
|
|
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
|
|
|
|