Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problem in datagridtextbox column

Problem in datagridtextbox column

Scheduled Pinned Locked Moved C#
csharphelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Shuaib wasif khan
    wrote on last edited by
    #1

    hell sir, i am working on datagrid control in c# window application i use datagridtextbox in datagrid . my probblem is that how can i do datagrid textbox column enable=false if it contains data =sunday my code is... try { dataGrid1.DataSource=null; dt.Clear(); dataGrid1.TableStyles.Clear(); ad=new SqlDataAdapter("select * from attendance where months='"+txtmonth.Text+"' and class='"+txtcurrentclass.Text+"' and section='"+txtsection.Text+"' and session='"+Class1.session+"'",cn); ad.Fill(dt); dt.Tables[0].DefaultView.AllowNew=false; dataGrid1.DataSource=dt.Tables[0]; DataGridTableStyle tbl=new DataGridTableStyle(); tbl.MappingName=dt.Tables[0].TableName; DataGridTextBoxColumn txt=new DataGridTextBoxColumn(); // txt.MappingName=dt.Tables[0].Columns["id"].ColumnName; // txt.HeaderText="SNo."; // txt.TextBox.BorderStyle=BorderStyle.FixedSingle; // txt.TextBox.Enabled=false; // txt.ReadOnly=true; // txt.Width=45; // txt.TextBox.BackColor=Color.Salmon; // txt.NullText="0"; // // tbl.GridColumnStyles.Add(txt); // txt=new DataGridTextBoxColumn(); txt.MappingName=dt.Tables[0].Columns["Studentcode"].ColumnName; txt.HeaderText="Student Code"; txt.ReadOnly=true;txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.TextBox.BackColor=Color.Salmon; txt.TextBox.Enabled=false; txt.TextBox.WordWrap=true; txt.Width=160; txt.Alignment=HorizontalAlignment.Left; tbl.GridColumnStyles.Add(txt); // txt=new DataGridTextBoxColumn(); txt.MappingName=dt.Tables[0].Columns["studentname"].ColumnName; txt.HeaderText="Name"; txt.TextBox.BorderStyle=BorderStyle.FixedSingle; txt.TextBox.Enabled=false; txt.TextBox.BackColor=Color.Salmon; txt.TextBox.ForeColor=Color.Blue; txt.ReadOnly=true; txt.Width=80; txt.Alignment=HorizontalAlignment.Center; tbl.GridColumnStyles.Add(txt); txt=new DataGridTextBoxColumn(); txt.MappingName=dt.Tables[0].Columns[4].ColumnName; txt.HeaderText="1 "+txtmonth.Text; txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.Alignment=HorizontalAlignment.Center; txt.Width=65; if(txt.TextBox.Text==DayOfWeek.Sunday.ToString()) { txt.ReadOnly=true; txt.TextBox.BackColor=Color.Red; } else { txt.ReadOnly=false; txt.TextBox.BackColor=Color.White; } tbl.GridC

    H 1 Reply Last reply
    0
    • S Shuaib wasif khan

      hell sir, i am working on datagrid control in c# window application i use datagridtextbox in datagrid . my probblem is that how can i do datagrid textbox column enable=false if it contains data =sunday my code is... try { dataGrid1.DataSource=null; dt.Clear(); dataGrid1.TableStyles.Clear(); ad=new SqlDataAdapter("select * from attendance where months='"+txtmonth.Text+"' and class='"+txtcurrentclass.Text+"' and section='"+txtsection.Text+"' and session='"+Class1.session+"'",cn); ad.Fill(dt); dt.Tables[0].DefaultView.AllowNew=false; dataGrid1.DataSource=dt.Tables[0]; DataGridTableStyle tbl=new DataGridTableStyle(); tbl.MappingName=dt.Tables[0].TableName; DataGridTextBoxColumn txt=new DataGridTextBoxColumn(); // txt.MappingName=dt.Tables[0].Columns["id"].ColumnName; // txt.HeaderText="SNo."; // txt.TextBox.BorderStyle=BorderStyle.FixedSingle; // txt.TextBox.Enabled=false; // txt.ReadOnly=true; // txt.Width=45; // txt.TextBox.BackColor=Color.Salmon; // txt.NullText="0"; // // tbl.GridColumnStyles.Add(txt); // txt=new DataGridTextBoxColumn(); txt.MappingName=dt.Tables[0].Columns["Studentcode"].ColumnName; txt.HeaderText="Student Code"; txt.ReadOnly=true;txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.TextBox.BackColor=Color.Salmon; txt.TextBox.Enabled=false; txt.TextBox.WordWrap=true; txt.Width=160; txt.Alignment=HorizontalAlignment.Left; tbl.GridColumnStyles.Add(txt); // txt=new DataGridTextBoxColumn(); txt.MappingName=dt.Tables[0].Columns["studentname"].ColumnName; txt.HeaderText="Name"; txt.TextBox.BorderStyle=BorderStyle.FixedSingle; txt.TextBox.Enabled=false; txt.TextBox.BackColor=Color.Salmon; txt.TextBox.ForeColor=Color.Blue; txt.ReadOnly=true; txt.Width=80; txt.Alignment=HorizontalAlignment.Center; tbl.GridColumnStyles.Add(txt); txt=new DataGridTextBoxColumn(); txt.MappingName=dt.Tables[0].Columns[4].ColumnName; txt.HeaderText="1 "+txtmonth.Text; txt.TextBox.BorderStyle=BorderStyle.FixedSingle;txt.Alignment=HorizontalAlignment.Center; txt.Width=65; if(txt.TextBox.Text==DayOfWeek.Sunday.ToString()) { txt.ReadOnly=true; txt.TextBox.BackColor=Color.Red; } else { txt.ReadOnly=false; txt.TextBox.BackColor=Color.White; } tbl.GridC

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      Investigate the OnCellPaint event handling.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups