Click here to Skip to main content
15,915,336 members
Home / Discussions / C#
   

C#

 
GeneralRe: Public member vs. public property Pin
mike montagne23-Feb-07 13:22
mike montagne23-Feb-07 13:22 
GeneralOh... and about Serialization and IDE processes Pin
mike montagne23-Feb-07 13:35
mike montagne23-Feb-07 13:35 
QuestionExcel: Problem with Datagrid-generated XML-file Pin
M.Vo.23-Feb-07 5:42
M.Vo.23-Feb-07 5:42 
QuestionForms Control Z Order Pin
BoneSoft23-Feb-07 5:33
BoneSoft23-Feb-07 5:33 
AnswerRe: Forms Control Z Order Pin
BoneSoft23-Feb-07 5:39
BoneSoft23-Feb-07 5:39 
AnswerRe: Forms Control Z Order Pin
kubben23-Feb-07 5:40
kubben23-Feb-07 5:40 
GeneralRe: Forms Control Z Order Pin
BoneSoft23-Feb-07 5:47
BoneSoft23-Feb-07 5:47 
QuestionCannot get datagridview to show records Pin
brainfuelmedia_23-Feb-07 5:07
brainfuelmedia_23-Feb-07 5:07 
I'm a noob to C#, so bear with me.

I have the following class and form:

<br />
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Data.SqlClient;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace tracker<br />
{<br />
    public partial class frmMain : Form<br />
    {<br />
        SqlConnection objDBConnection;<br />
        SqlDataAdapter objDBAdapter;<br />
        DataSet objDBDataSet;<br />
        DataGridView objDBGridView;<br />
<br />
        public frmMain()<br />
        {<br />
            InitializeComponent();<br />
        }<br />
<br />
        private void frmMain_Load(object sender, EventArgs e)<br />
        {<br />
            this.objDBConnection = new SqlConnection("Server=BigHouse;Database=tracker;Trusted_Connection=yes");<br />
            try<br />
            {<br />
                this.objDBConnection.Open();<br />
                this.toolStripStatusLabel1.Text = "Connected to Tracker database";<br />
            }<br />
            catch (Exception connerr)<br />
            {<br />
                this.toolStripStatusLabel1.Text = "Cannot connect to Tracker database";<br />
            }<br />
<br />
            <br />
            this.getProjectGridData();<br />
<br />
            /* test data */<br />
            DataRow r = this.objDBDataSet.Tables["tbl_projects_main"].Rows[0];<br />
            Console.WriteLine("num records = " + <br />
                                this.objDBDataSet.Tables["tbl_projects_main"].Rows.Count + <br />
                                " and " + <br />
                                r["prj_name"].ToString());<br />
            /* END test data */<br />
<br />
            this.objDBGridView = new DataGridView();<br />
            this.objDBGridView.DataSource = this.objDBDataSet.Tables["tbl_projects_main"];<br />
            this.objDBGridView.AutoGenerateColumns = true;<br />
            this.objDBGridView.Location = new Point(0, 0);<br />
            this.objDBGridView.Size = new Size(700, 490);<br />
            this.objDBGridView.MinimumSize = new Size(700, 490);<br />
            this.objDBGridView.BackgroundColor = System.Drawing.Color.AliceBlue;<br />
            this.objDBGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);<br />
            <br />
            this.objDBGridView.Visible = true;<br />
        }<br />
<br />
        private void getProjectGridData()<br />
        {<br />
            string strSql;<br />
            strSql = "SELECT * FROM dbo.tbl_projects_main";<br />
            this.objDBDataSet = new DataSet();<br />
            this.objDBAdapter = new SqlDataAdapter();<br />
            this.objDBAdapter.SelectCommand = new SqlCommand(strSql, this.objDBConnection);<br />
            this.objDBAdapter.Fill(this.objDBDataSet, "tbl_projects_main");<br />
        }<br />
    }<br />
}<br />


I know I'm getting records and info back from the database, but nothing shows up on my form - no datagridview to be seen anywhere.

Any help is appreciated.
AnswerRe: Cannot get datagridview to show records Pin
kubben23-Feb-07 5:32
kubben23-Feb-07 5:32 
AnswerRe: Cannot get datagridview to show records Pin
Drew McGhie23-Feb-07 5:48
Drew McGhie23-Feb-07 5:48 
GeneralRe: Cannot get datagridview to show records Pin
brainfuelmedia_23-Feb-07 5:56
brainfuelmedia_23-Feb-07 5:56 
GeneralRe: Cannot get datagridview to show records Pin
Drew McGhie23-Feb-07 6:00
Drew McGhie23-Feb-07 6:00 
QuestionRemoting Pin
Saaaaz23-Feb-07 4:48
Saaaaz23-Feb-07 4:48 
AnswerRe: Remoting Pin
Obaid ur Rehman23-Feb-07 6:02
Obaid ur Rehman23-Feb-07 6:02 
GeneralRe: Remoting Pin
Saaaaz25-Feb-07 8:13
Saaaaz25-Feb-07 8:13 
GeneralRe: Remoting Pin
Saaaaz27-Feb-07 3:12
Saaaaz27-Feb-07 3:12 
QuestionInheritance Pin
#realJSOP23-Feb-07 4:25
professional#realJSOP23-Feb-07 4:25 
AnswerRe: Inheritance Pin
led mike23-Feb-07 4:38
led mike23-Feb-07 4:38 
GeneralRe: Inheritance Pin
#realJSOP23-Feb-07 4:42
professional#realJSOP23-Feb-07 4:42 
GeneralRe: Inheritance Pin
led mike23-Feb-07 4:57
led mike23-Feb-07 4:57 
GeneralRe: Inheritance Pin
BoneSoft23-Feb-07 5:59
BoneSoft23-Feb-07 5:59 
GeneralRe: Inheritance Pin
#realJSOP23-Feb-07 6:12
professional#realJSOP23-Feb-07 6:12 
GeneralRe: Inheritance Pin
led mike23-Feb-07 6:36
led mike23-Feb-07 6:36 
AnswerRe: Inheritance Pin
Pete O'Hanlon23-Feb-07 4:42
mvePete O'Hanlon23-Feb-07 4:42 
AnswerRe: Inheritance Pin
Colin Angus Mackay23-Feb-07 4:45
Colin Angus Mackay23-Feb-07 4:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.