Click here to Skip to main content
15,884,099 members
Home / Discussions / C#
   

C#

 
GeneralRe: Click here to send data to sever!! Pin
yum 20103-Jul-10 11:26
yum 20103-Jul-10 11:26 
QuestionAmazon API and C# Pin
tonyonlinux2-Jul-10 10:16
tonyonlinux2-Jul-10 10:16 
AnswerRe: Amazon API and C# Pin
Abhinav S2-Jul-10 17:57
Abhinav S2-Jul-10 17:57 
GeneralRe: Amazon API and C# Pin
tonyonlinux2-Jul-10 18:39
tonyonlinux2-Jul-10 18:39 
QuestionChange Row background color based by cell value Pin
grmihel22-Jul-10 5:14
grmihel22-Jul-10 5:14 
AnswerRe: Change Row background color based by cell value Pin
Henry Minute2-Jul-10 7:07
Henry Minute2-Jul-10 7:07 
AnswerRe: Change Row background color based by cell value Pin
Henry Minute2-Jul-10 8:37
Henry Minute2-Jul-10 8:37 
GeneralRe: Change Row background color based by cell value [modified] Pin
grmihel25-Jul-10 0:43
grmihel25-Jul-10 0:43 
Hi there,

Thnx for your experimenting, making me a step closer to understand how it work behind. I'm affraid that as you say, the values ain't intergers but strings. I know that the values I have into the cells ARE intergers (count of subscribers in a interger). But seems that the parsing from string to interger won't work.
Any ideas?

I have decided to show some more source code, since it seems that my _databindingComplete event doesn't even trigger. Sorry for some words in danish (tell me if you need any explained):
public partial class KundeStat_GUI : Form
    {
        private FrontController Controller = FrontController.Instance;
        //private DataGridView grid;

        private decimal fiberbyTotal_tilmeldt = 0;
        private decimal fiberbyTotal_utilmeldt = 0;
        private decimal fiberbytotal_særaftale = 0;
        private decimal serviceTotal_tilmeldt = 0;
        private decimal serviceTotal_utilmeldt = 0;
        private decimal serviceTotal_særaftale = 0;
        private decimal erhvervTotal_tilmeldt = 0;
        private decimal erhvervTotal_utilmeldt = 0;
        private decimal erhvervTotal_særaftale = 0;

        public KundeStat_GUI()
        {
            InitializeComponent();
        }

        private void KundeStat_GUI_Load(object sender, EventArgs e)
        {
            Dictionary<string, DataGridView> datas = new Dictionary<string, DataGridView>();
            

            foreach (Kundetype item in Controller.HentAlleKundetyper())
            {
		//grid are specified in KundeStat_GUI.Designer.cs
                grid = new DataGridView();
                grid.Columns.Add("nummer1", "Foreningsnavn");
                grid.Columns.Add("nummer2", "Tilmeldte");
                grid.Columns.Add("nummer3", "Ikke tilmeldt");
                grid.Columns.Add("nummer4", "Særaftale");
                grid.Columns.Add("nummer5", "Potentielle");
                grid.Columns.Add("nummer6", "% tilslutning");

                grid.Columns[0].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                grid.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                grid.Columns[2].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                grid.Columns[3].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                grid.Columns[4].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                grid.Columns[5].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
                grid.Columns[5].ValueType = typeof(decimal);

                grid.ReadOnly = true;
                grid.AllowUserToAddRows = false;
                grid.AllowUserToDeleteRows = false;
                grid.RowHeadersVisible = false;
                grid.Dock = DockStyle.Fill;
                datas.Add(item.Type, grid);
                TabPage tp = new TabPage(item.Type);
                tp.Controls.Add(grid);
                tabControl1.TabPages.Add(tp);
            }

            foreach (Kunde item in Controller.HentAlleKunder())
            {
                decimal tilmeldte = 0;
                decimal ikketilmeldt = 0;
                decimal særaftale = 0;
                foreach (Lejlighed item1 in item.Lejligheds)
                {
                    #region 24ports switch
                    if (item1.Switch.AntalPorte == 26)
                    {
			/*Do some coding*/
                    }
                    #endregion
                    #region 48ports switch
                    else if (item1.Switch.AntalPorte == 50)
                    {
                        /*Do some coding*/
                    }
                    #endregion
                }
                decimal procent = 0;
                try
                {
                    procent = (tilmeldte / (tilmeldte + ikketilmeldt)) * 100;
                }
                catch (DivideByZeroException)
                {

                }
                
                datas[item.Kundetype.Type].Rows.Add(item.KundeNavn, tilmeldte, ikketilmeldt, særaftale, tilmeldte + ikketilmeldt, procent.ToString("###"));
            }

            //HACK
            foreach(Kundetype kundet in Controller.HentAlleKundetyper())
            {
                decimal procentTotal = 0;
                try
                {
                    if (kundet.Type.Equals("Fiberby"))
                        procentTotal = (fiberbyTotal_tilmeldt / (fiberbyTotal_tilmeldt + fiberbyTotal_utilmeldt)) * 100;
                    if (kundet.Type.Equals("Serviceaftale"))
                        procentTotal = (serviceTotal_tilmeldt / (serviceTotal_tilmeldt + serviceTotal_utilmeldt)) * 100;
                    if (kundet.Type.Equals("Erhverv"))
                        procentTotal = (erhvervTotal_tilmeldt / (erhvervTotal_tilmeldt + erhvervTotal_utilmeldt)) * 100;
                }
                catch (DivideByZeroException)
                {
                }
                if (kundet.Type.Equals("Fiberby"))
                    datas[kundet.Type].Rows.Add("Total", fiberbyTotal_tilmeldt, fiberbyTotal_utilmeldt, fiberbytotal_særaftale, fiberbyTotal_tilmeldt + fiberbyTotal_utilmeldt, procentTotal.ToString("###") + "%");
                else if (kundet.Type.Equals("Serviceaftale"))
                    datas[kundet.Type].Rows.Add("Total", serviceTotal_tilmeldt, serviceTotal_utilmeldt, serviceTotal_særaftale, serviceTotal_tilmeldt + serviceTotal_utilmeldt, procentTotal.ToString("###") + "%");
                else if (kundet.Type.Equals("Erhverv"))
                    datas[kundet.Type].Rows.Add("Total", erhvervTotal_tilmeldt, erhvervTotal_utilmeldt, erhvervTotal_særaftale, erhvervTotal_tilmeldt + erhvervTotal_utilmeldt, procentTotal.ToString("###") + "%");
                else
                    datas[kundet.Type].Rows.Add("Total", "", "", "", "", procentTotal.ToString("###") + "%");
            }
            //end
        }

        private void grid_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            if (e.ListChangedType != ListChangedType.ItemDeleted)
            {
                DataGridViewCellStyle red = grid.DefaultCellStyle.Clone();
                red.BackColor = Color.LightPink;

                foreach (DataGridViewRow r in grid.Rows)
                {
                    if ((int)r.Cells["nummer6"].Value < 50)
                    {
                        r.DefaultCellStyle = red;
                    }
                }

            }
        }
    }


And here is a view of some of the designer generated code:
private void InitializeComponent()
{
    this.tabControl1 = new System.Windows.Forms.TabControl();
    this.grid = new System.Windows.Forms.DataGridView();
    this.SuspendLayout();
    //
    // tabControl1
    //
    this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                | System.Windows.Forms.AnchorStyles.Left)
                | System.Windows.Forms.AnchorStyles.Right)));
    this.tabControl1.Location = new System.Drawing.Point(2, 57);
    this.tabControl1.Name = "tabControl1";
    this.tabControl1.SelectedIndex = 0;
    this.tabControl1.Size = new System.Drawing.Size(738, 539);
    this.tabControl1.TabIndex = 1;
    //
    // grid
    //
    this.grid.DataBindingComplete += new System.Windows.Forms.DataGridViewBindingCompleteEventHandler(this.grid_DataBindingComplete);

}

#endregion

private System.Windows.Forms.TabControl tabControl1;
private System.Windows.Forms.DataGridView grid;



Any1 who can see the link of why grid_databindingComplete() doesn't trigger?

modified on Monday, July 5, 2010 7:27 AM

GeneralRe: Change Row background color based by cell value Pin
Henry Minute5-Jul-10 3:34
Henry Minute5-Jul-10 3:34 
GeneralRe: Change Row background color based by cell value Pin
grmihel26-Jul-10 3:27
grmihel26-Jul-10 3:27 
QuestionI want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 5:03
professionalNagy Vilmos2-Jul-10 5:03 
AnswerRe: I want a Clever Text Display Pin
R. Giskard Reventlov2-Jul-10 5:12
R. Giskard Reventlov2-Jul-10 5:12 
AnswerRe: I want a Clever Text Display Pin
OriginalGriff2-Jul-10 5:32
mveOriginalGriff2-Jul-10 5:32 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 5:46
professionalNagy Vilmos2-Jul-10 5:46 
AnswerRe: I want a Clever Text Display Pin
OriginalGriff2-Jul-10 5:33
mveOriginalGriff2-Jul-10 5:33 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 5:47
professionalNagy Vilmos2-Jul-10 5:47 
GeneralRe: I want a Clever Text Display Pin
OriginalGriff2-Jul-10 5:54
mveOriginalGriff2-Jul-10 5:54 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 7:14
professionalNagy Vilmos2-Jul-10 7:14 
AnswerRe: I want a Clever Text Display Pin
Luc Pattyn2-Jul-10 7:03
sitebuilderLuc Pattyn2-Jul-10 7:03 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 7:12
professionalNagy Vilmos2-Jul-10 7:12 
GeneralRe: I want a Clever Text Display Pin
Luc Pattyn2-Jul-10 7:20
sitebuilderLuc Pattyn2-Jul-10 7:20 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 10:53
professionalNagy Vilmos2-Jul-10 10:53 
GeneralRe: I want a Clever Text Display Pin
Luc Pattyn2-Jul-10 11:31
sitebuilderLuc Pattyn2-Jul-10 11:31 
GeneralRe: I want a Clever Text Display Pin
Nagy Vilmos2-Jul-10 21:44
professionalNagy Vilmos2-Jul-10 21:44 
GeneralRe: I want a Clever Text Display Pin
Mycroft Holmes2-Jul-10 22:31
professionalMycroft Holmes2-Jul-10 22:31 

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.