Click here to Skip to main content
15,902,447 members
Home / Discussions / C#
   

C#

 
Questionhow to fill the cells of a DataGridView directly Pin
Member 114494479-Dec-15 1:49
Member 114494479-Dec-15 1:49 
AnswerRe: how to fill the cells of a DataGridView directly Pin
Richard MacCutchan9-Dec-15 2:37
mveRichard MacCutchan9-Dec-15 2:37 
GeneralRe: how to fill the cells of a DataGridView directly Pin
Member 114494479-Dec-15 3:58
Member 114494479-Dec-15 3:58 
GeneralRe: how to fill the cells of a DataGridView directly Pin
Richard Deeming9-Dec-15 4:02
mveRichard Deeming9-Dec-15 4:02 
GeneralRe: how to fill the cells of a DataGridView directly Pin
Member 114494479-Dec-15 4:30
Member 114494479-Dec-15 4:30 
GeneralRe: how to fill the cells of a DataGridView directly Pin
Richard Deeming9-Dec-15 4:44
mveRichard Deeming9-Dec-15 4:44 
GeneralRe: how to fill the cells of a DataGridView directly Pin
Member 114494479-Dec-15 6:37
Member 114494479-Dec-15 6:37 
QuestionChild Window Form does not show color scheme on gridview Pin
Member 121312778-Dec-15 23:39
Member 121312778-Dec-15 23:39 
I design a form which show color scheme on datagridview(alternate rows).it work fine. But when I call it from mdi parent form menu strip tab, Then it does not show color on datagridview(which fill on form load function).When I run only child form it shows like color on gridview3 and datagridview4.But when I call from parent then it does not show color in datagridview3(alternate rows) and datagridview4(alternate rows).



C#
private void Form1_Load(object sender, EventArgs e)
{
    comboBox1.SelectedItem = "Select Gender";

    using (SqlConnection con = new SqlConnection(conn))
    {

        SqlDataAdapter sda = new SqlDataAdapter("getdata", con);
        sda.SelectCommand.CommandType = CommandType.StoredProcedure;
        DataSet ds = new DataSet();
        sda.Fill(ds);
        ds.Tables[0].TableName = "Product";
        ds.Tables[1].TableName = "Category";

        dataGridView3.DataSource = ds.Tables["Product"];
        dataGridView4.DataSource = ds.Tables["Category"];


    }
    gridrowcolor();


}
public void gridrowcolor()
{
    DataGridViewCellStyle st = new DataGridViewCellStyle();
    st.Font = new Font("Arial", 12, FontStyle.Bold);

    for (int i = 0; i < dataGridView4.Rows.Count-1; i++)
    {
        //dataGridView4.RowsDefaultCellStyle.BackColor = Color.Orange;
        //dataGridView4.AlternatingRowsDefaultCellStyle.BackColor = Color.BurlyWood;

        int ii = Convert.ToInt32(dataGridView4.Rows[i].Cells[0].Value.ToString());
        if (ii % 2 == 0)
        {
            dataGridView4.Rows[i].DefaultCellStyle.BackColor = Color.Gray;
            dataGridView4.Rows[i].DefaultCellStyle = st;
        }
        else
            dataGridView4.Rows[i].DefaultCellStyle.BackColor = Color.Brown;
    }

    for (int i = 0; i < dataGridView3.Rows.Count - 1; i++)
    {


        dataGridView3.CellBorderStyle = DataGridViewCellBorderStyle.None;
        DataGridViewCellStyle style = new DataGridViewCellStyle();
        style.Font = new Font(dataGridView3.Font, FontStyle.Bold);

        int ii = Convert.ToInt32(dataGridView3.Rows[i].Cells[0].Value.ToString());
        if (ii % 2 == 0)
        {
            dataGridView3.Rows[i].DefaultCellStyle.BackColor = Color.Yellow;
            dataGridView3.Rows[i].DefaultCellStyle = style;
            dataGridView3.DefaultCellStyle.SelectionForeColor = Color.Chocolate;
        }
        else
            dataGridView3.Rows[i].DefaultCellStyle.BackColor = Color.Orange;
    }
}


From Parent MDI Form

C#
private void receiptCancelRequestToolStripMenuItem_Click(object sender, EventArgs e)
{
    Form1 frm = new Form1();
    frm.MdiParent = this;
    frm.Show();

}


modified 9-Dec-15 6:37am.

SuggestionRe: Child Window Form does not show color scheme on gridview Pin
Richard MacCutchan9-Dec-15 0:13
mveRichard MacCutchan9-Dec-15 0:13 
Questionc# for android Pin
eng_aza8-Dec-15 14:03
eng_aza8-Dec-15 14:03 
AnswerRe: c# for android Pin
Dave Kreskowiak8-Dec-15 15:27
mveDave Kreskowiak8-Dec-15 15:27 
AnswerRe: c# for android Pin
BillWoodruff8-Dec-15 16:14
professionalBillWoodruff8-Dec-15 16:14 
AnswerRe: c# for android Pin
Hari-CodeBlogger11-Dec-15 23:44
Hari-CodeBlogger11-Dec-15 23:44 
QuestionTransfer data from Dataset to Report Viewer Pin
PDTUM8-Dec-15 8:32
PDTUM8-Dec-15 8:32 
AnswerRe: Transfer data from Dataset to Report Viewer Pin
Gerry Schmitz8-Dec-15 12:29
mveGerry Schmitz8-Dec-15 12:29 
GeneralRe: Transfer data from Dataset to Report Viewer Pin
PDTUM8-Dec-15 12:53
PDTUM8-Dec-15 12:53 
GeneralRe: Transfer data from Dataset to Report Viewer Pin
Gerry Schmitz8-Dec-15 13:29
mveGerry Schmitz8-Dec-15 13:29 
GeneralRe: Transfer data from Dataset to Report Viewer Pin
PDTUM8-Dec-15 14:14
PDTUM8-Dec-15 14:14 
QuestionIncomplete data after trapping Date Pin
Robert Kamarowski8-Dec-15 5:38
Robert Kamarowski8-Dec-15 5:38 
AnswerRe: Incomplete data after trapping Date Pin
Richard Deeming8-Dec-15 6:11
mveRichard Deeming8-Dec-15 6:11 
GeneralRe: Incomplete data after trapping Date Pin
Robert Kamarowski8-Dec-15 6:18
Robert Kamarowski8-Dec-15 6:18 
GeneralRe: Incomplete data after trapping Date Pin
OriginalGriff8-Dec-15 6:37
mveOriginalGriff8-Dec-15 6:37 
GeneralRe: Incomplete data after trapping Date Pin
Dave Kreskowiak8-Dec-15 7:43
mveDave Kreskowiak8-Dec-15 7:43 
GeneralRe: Incomplete data after trapping Date Pin
Richard Deeming8-Dec-15 7:51
mveRichard Deeming8-Dec-15 7:51 
GeneralRe: Incomplete data after trapping Date Pin
Robert Kamarowski8-Dec-15 8:17
Robert Kamarowski8-Dec-15 8:17 

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.