Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 131,712 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 2,394 people online right now. Registration is fast and FREE... Join Now!




delete all posts in dataGridView and save to database

 
Reply to this topicStart new topic

delete all posts in dataGridView and save to database

twebbas
post 9 Oct, 2008 - 01:39 PM
Post #1


New D.I.C Head

*
Joined: 9 Oct, 2008
Posts: 3

Hi all.

I'm developing a little reminder program. It's pretty basic.
You can choose what you want to be reminded about (a simple textbox) and what date/time you want this reminder to remind you.
I also added a basic settings form giving the user the chance to change font color and such.

a) I've managed to delete the rows in the datagrid with
CODE
database1DataSet.Clear();
OR using
CODE
dataGridView1.DataSource = null;

but when I try to update using
CODE
rememberTableAdapter.Update(database1DataSet);
it doesn't work. The grid IS cleared. But the next time I'm opening that form,
all the data is back. So somehow it doesn't save to the database I guess.

I have a button which allows the user to edit the grid with
CODE
dataGridView1.ReadOnly = false;

And when done editing the user can hit the save button
CODE
            
dataGridView1.ReadOnly = true;
rememberTableAdapter.Update(database1DataSet);


This DOES work. When exiting the program (or that form) it's stored in the database. So the update does work in that case.
But it doesn't work when clearing the grid first??

cool.gif The other thing is, in my settings, the user can change the background color and font color using 5 different themes.
I'm using a simple dropdownlist for the task.
I used the following code for the color change
CODE
          
if (comboBox1.SelectedItem == comboBox1.Items[0])
            {
            this.ForeColor = Color.White;
            this.BackColor = Color.Black;
            }


This does only change the color on the current form. And the next time I open that form, it's back to the default colors.
How do I access the other forms settings? If the user change colors, the change should be for all forms.
Is there not a default application setting I can change? (so that changing it would change the looks on all forms in the application)
Or do I have to access it using properties? Never got the hang of that though..

Thnx =)

This post has been edited by twebbas: 9 Oct, 2008 - 02:08 PM
User is offlineProfile CardPM

Go to the top of the page

fooboo
post 10 Oct, 2008 - 02:44 AM
Post #2


The king of Nynex

Group Icon
Joined: 28 Jul, 2006
Posts: 2,815



Thanked 1 times

Dream Kudos: 150
My Contributions


I'm no expert but I thought I'd mention that I have seen the colour change that you mentioned handled by css rather than per form. That way you just need to change the css you are using and the whole site can be changed rather than changing each forms colour settings in turn.

I'm still new to this myself so I can't remember exactly how it was done but I believe when making site wide colour changes css is the easiest way to do it and is abstracted from the code so it keeps the code and the styling seperate which makes it easier to manage.
User is offlineProfile CardPM

Go to the top of the page

twebbas
post 10 Oct, 2008 - 11:32 AM
Post #3


New D.I.C Head

*
Joined: 9 Oct, 2008
Posts: 3

Thx for the answer. I know about css on homepages and such. But the thing is, this ones for offline use only. Just a normal program. Not a website. wink2.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 09:37AM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month