Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

printpreview for datagridview

gridview grid datagridview

  • Please log in to reply
8 replies to this topic

#1 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 01 March 2011 - 03:17 PM

hy i'm using .mdf table...in source i'm using sql query for creating tables (database is created in SQL Server Management Studio...all i want is when i click on button "print" that i have print preview of dataGridView table...i know how to get printpreview but i don't know how to connect datagridview to printpreview...table is named Tehnicar_za_racunalstvo...and i get values in table from textBox controls...that's all information i can give

this is the line from which i get print preview

printPreviewDialog1.ShowDialog();
any help???
  • 0

#2 CommittedC0der

CommittedC0der

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1065 posts
  • Programming Language:C#
  • Learning:C#, JavaScript, PL/SQL

Posted 01 March 2011 - 06:29 PM

This tutorial should help you. :)
How To Print a Data Grid in C# and .NET

~ Committed.
  • 1
There IS a war going on for your mind.
Nothing of eternal significance happens besides prayer.

#3 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 02 March 2011 - 08:42 AM

i have created columns using xml
so i need to create a new row in dataGridView control with mouse click on button for creating a new row...
i've seen so many tuttorials but neither helped me...
first i need to open that xml into dataGridView (my xml file is named Teh_za_rac.xml)
and then i should add a new row in that table by click on button
my dataGridView is named Tablica1
can you please help me
  • 0

#4 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 02 March 2011 - 10:33 AM

no matters i've done it
  • 0

#5 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 02 March 2011 - 10:57 AM

sorry Committed but i didn't understand that tutorial
i don't know what to do, this is the final thing for my project
  • 0

#6 sam_coder

sam_coder

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 380 posts

Posted 02 March 2011 - 01:57 PM

you should check out crystal reports
I think that's what you want. It wouldn't print or offer print preview from the data grid view,
but it would from the underlying database. That's what you want.

Crystal Reports ships with Visual Studio, so you should just be able to add a report to your application
Then you can use a Crystal Reports Viewer, and load the report. The viewer has all the preview and print functionality you need. It even allows you to customize the report, to your liking, with pretty much everything you could imagine.
  • 0

#7 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 03 March 2011 - 12:35 PM

can you give me site where i can learn what crystal report is, few examples,...
and can you teach me technique how to save values from datagridview into mdf database
  • 0

#8 Tonchi

Tonchi

    Helping the world with programming

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1249 posts
  • Location:Zagreb
  • Programming Language:C#, Others
  • Learning:C, C++, Python, JavaScript, Transact-SQL, Assembly

Posted 07 March 2011 - 03:26 AM

i have finished that print preview with DGVPrinter...check on google
and my program works well when i'm sorting rows with Bodovi column (i've put xml into dataGridView so it opens table when i click on Button Stvori)
this is code for my Button Stvori
private void button1_Click(object sender, EventArgs e)
        {

            XmlDataDocument xmlDatadoc = new XmlDataDocument();
            xmlDatadoc.DataSet.ReadXml("C:\\EtsDtb\\EtsDtb\\bin\\Debug\\Elektrotehnicar.xml");
            DataSet ds = new DataSet("Tablica");
            ds = xmlDatadoc.DataSet;
            Tablica1.DataSource = ds.DefaultViewManager;
            Tablica1.DataMember = "Elektrotehničar";
        }
and to not forget to tell my problem is when i click on column name Bodovi it sometimes gives me error and error says that if i want to countinue working in program i have to click continue and if not i have to click quit...but when i click continue it erase everything from table so i lost all my informations...how can i fix it???
here is XML code if you need it
<?xml version="1.0" encoding="utf-8" ?>
<Ime>
  <Elektrotehničar>
    <Ime> </Ime>
    <Prezime> </Prezime>
    <Datum_Rođenja> </Datum_Rođenja>
    <Učeni_Jezik> </Učeni_Jezik>
    <Religijski_Predmet> </Religijski_Predmet>
    <Dodatni_Bodovi> </Dodatni_Bodovi>
    <Br_Dod_Bodova> </Br_Dod_Bodova>
    <Matematika_7> </Matematika_7>
    <Matematika_8> </Matematika_8>
    <Hrvatski_7> </Hrvatski_7>
    <Hrvatski_8> </Hrvatski_8>
    <Strani_Jezik_7> </Strani_Jezik_7>
    <Strani_Jezik_8> </Strani_Jezik_8>
    <Fizika_7> </Fizika_7>
    <Fizika_8> </Fizika_8>
    <Teh_Kultura_7> </Teh_Kultura_7>
    <Teh_Kultura_8> </Teh_Kultura_8>
    <Prosjek_7> </Prosjek_7>
    <Prosjek_8> </Prosjek_8>
    <Ponavljač> </Ponavljač>
    <Bodovi> </Bodovi>


  </Elektrotehničar>
</Ime>
i need to fix it so i can finally be finished with my program
  • 0

#9 saviolan

saviolan

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 02 February 2012 - 11:22 AM

C# datagridview printing source code

C# DataGridView Printing

savs.
  • 0





Also tagged with one or more of these keywords: gridview, grid, datagridview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download