I found an answer. Using System.Drawing.ColorTranslator.FromWin32() instead of ArgB();
perry59
Posts
-
Fill datagridview cell with color -
Fill datagridview cell with colorI want to fill the cells of a datagridview column based on numbers derived at runtime. Sounds easy enough but... these two lines of code work great if I only wanted red dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.Red; dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.Red; but these two lines just color the cells text (if existing)? or they just act bizzarly(although they worked good with a listview) dataGridView1.Rows[layerCount].Cells[3].Style.BackColor = Color.FromArgb(swLayer.Color); dataGridView1.Rows[layerCount].Cells[3].Style.ForeColor = Color.FromArgb(swLayer.Color); Anyone have any pointer? wait a minute, no POINTERS, how about advice :)
-
ADOX making me crazy, please helpIm trying to create an access database with ADOX. It is to contain 3 tables, each with a primary and foreign key and a one-to-one relationship between each table. I have no problem creating and populating the tables, no problem adding indexes to each table (one index is also a primary key). When I try to add primary keys to any tables that do not already have one, it bombs out. I've scoured everything I can find on ADOX (most of its VB) and nothing helps and some examples I found were bad or confusing. I'm also not sure if simply creating the primary/foreign keys will create a relationship of if there is something else I must do. I've posted my code below with comments on the problem areas, I appreciate any help (while I still have hair left) ! -------------------------------------------------------------------------------
/// /// Create new database file /// /// public static void CreateDb(string fileName) { // append function prototype // Append(object Item, ADOX.KeyTypeEnum Type, object Column, string RelatedTable, string RelatedColumn) ADOX.CatalogClass cat = new ADOX.CatalogClass(); ADOX.Table tblNew = new ADOX.Table(); ADOX.Index tblIdx = new ADOX.Index(); ADOX.Key tblKey = new ADOX.Key(); // Create database and add tables try { cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Jet OLEDB:Engine Type=5"); // Create the CUSTOMERS table tblNew.Name = "Customers"; tblNew.ParentCatalog = cat; tblNew.Columns.Append("CustomerID", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("MachineType", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Name", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Address", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("City", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("State", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Zip", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Country", ADOX.DataTypeEnum.adWChar, 50); tblNew.Columns.Append("Status", ADOX.DataTypeEnum.adWChar, 50); cat.Tables.Append(tblNew); tblNew = null; // Create the DRA