DdoubleD 315 Posting Shark

There is no need to create a new style as I demonstrated in that example. You can just set the default style:

DataGridViewRow row = new DataGridViewRow();
            row.DefaultCellStyle.ForeColor = Color.Green;
            dataGridView1.Rows.Add(row);

Also, the event handler that Ryshad gave is a more versatile approach and you could set the entire row's ForeColor too instead of individual cells if that is your intention.

DdoubleD 315 Posting Shark

Modify your new rode with new style:

DataGridViewRow row = new DataGridViewRow();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            style.ForeColor = Color.Green; // the color change
            row.DefaultCellStyle = style;
            dataGridView1.Rows.Add(row);
DdoubleD 315 Posting Shark

Modify your new rode with new style:

DataGridViewRow row = new DataGridViewRow();
            DataGridViewCellStyle style = new DataGridViewCellStyle();
            style.ForeColor = Color.Green; // the color change
            row.DefaultCellStyle = style;
            dataGridView1.Rows.Add(row);
DdoubleD 315 Posting Shark

You have declared item Post item; to be abstract class reference, which does not contain an object called "title". Set your derived class specific objects like:

if (type == "regular")
            {
                RegularPost regularPost = new RegularPost(); // specific stuff
                item = regularPost; // reference to common stuff...

                regularPost.title = (string)postType.ElementAt(0);
                regularPost.body = (string)postType.ElementAt(1);

Then, "item" can still set the abstract objects that are common. Repeat this for the other derived objects.

DdoubleD 315 Posting Shark

MSDN:
The programmer has no control over when the destructor is called because this is determined by the garbage collector. The garbage collector checks for objects that are no longer being used by the application. If it considers an object eligible for destruction, it calls the destructor (if any) and reclaims the memory used to store the object. Destructors are also called when the program exits.

Take a look at these:
Destructors
Dispose

DdoubleD 315 Posting Shark

Its that line which has the child class specific field. The one with item.title and all the others with child specific fields.

OK, so item.title in this code segment?:

if (type == "regular")
                {
                        item = new RegularPost();
 
                        item.title = (string)postType.ElementAt(0);
                        item.body = (string)postType.ElementAt(1);
                }

What is the definition of: Tumblarity.Post , which I assume is the object being returned by method RegularPost() ?

And, if you really want fast results, zip up your project and attach it so I can build it and reproduce the error quickly...

DdoubleD 315 Posting Shark

What line number of the original code gave you that error you said in the beginning?

DdoubleD 315 Posting Shark

There are so many examples of this inside this forum, many including entire zipped up projects. Begin by taking a look at some of these and if you have problems, just let us know...

DdoubleD 315 Posting Shark

Is there any way to declare a single variable which can change its type depending upon the type of post? It should also be accessible so as to be added to a list.

A reference of type object can be set to any type. Then, you can determine type with typeof(string) or typeof(int) or typeof(Post) etc. .

DdoubleD 315 Posting Shark

Alba, I don't really know this game, but I did spot a couple of things I thought worth mentioning. Have you stepped through each line of this code to see if what is happening?

I noticed you are incrementing GlobalVariables.countresultslots at the beginning of each loop, and then referencing an element of ResultForm.SlotField[GlobalVariables.countresultslots] from that location. On the surface, this looks very suspicious because usually array/list elements are not referenced higher than Count - 1 .

You also calculate an indexer several times for the same purpose of referencing an element: [(GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i] . Not only is this redundant and a waste of processing time, but it makes it more difficult to watch what is happening. I suggest breaking the calculation out, for example:

// change
ResultForm.ResultLabel[(GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i].AutoSize = true;
    ResultForm.ResultLabel[(GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i].Location = new Point((GlobalVariables.configsetup[0] + i)* 60, (GlobalVariables.guesscounter - 1) * 60);
    ResultForm.ResultLabel[(GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i].Size = new System.Drawing.Size(42, 20);
    ResultForm.ResultLabel[(GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i].TabIndex = 0;
    ResultForm.ResultLabel[(GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i].Enabled = false;

// to something like:
            int index = (GlobalVariables.countresultslots / (GlobalVariables.configsetup[0] + 2)) + i;
            ResultForm.ResultLabel[index].AutoSize = true;
            ResultForm.ResultLabel[index].Location = new Point((GlobalVariables.configsetup[0] + i) * 60, (GlobalVariables.guesscounter - 1) * 60);
            ResultForm.ResultLabel[index].Size = new System.Drawing.Size(42, 20);
            ResultForm.ResultLabel[index].TabIndex = 0;
            ResultForm.ResultLabel[index].Enabled = false;

That also makes it easier to read and there won't be a need to create a temporary storage to …

DdoubleD 315 Posting Shark

Anteka, very good reply! I had to look up the SOS (Spiritually Optimized System) acronym though--LOL.

DdoubleD 315 Posting Shark

Is the data structure static in that it will always be in the format exampled?

DdoubleD 315 Posting Shark

LabelPanel huh...very interesting!:P

DdoubleD 315 Posting Shark

Ooooooh Scott, come on man, I know you know the answer... ;) Help us out please?

DdoubleD 315 Posting Shark

DdoubleD: why do you only set the Password to IntPtr and do the Marshling? Why not username and domain also?

Because of this prototype declaration I found (see below). It's possible that it is incorrect because I just pulled it off the web and not from MSDN, which we know is always correct too--LOL.

Anyway, after really thinking about it, I doubt seriously that prototype is correct using "String" in a Win32 API call. Also, look at the variable naming convention: lpsz, or long pointer to null-terminated string (long pointer to null terminated char array in C/CPP; aka char*).

The answer is near though...

/// 
        /// The LogonUser function attempts to log a user on to the local computer.
        /// 
        [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern bool LogonUser(String lpszUsername, String lpszDomain, IntPtr lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr hToken);
DdoubleD 315 Posting Shark

Remember you, remember me,
And if at all, we should disagree,
To help with you, remember me.

You didn't invite me to the goodbye party, so I thought I would make an entrance... Best wishes Serkan.

DdoubleD 315 Posting Shark

Check out this thread:
http://www.daniweb.com/forums/thread209516.html

I believe there is some confusion in the beginning of the thread concerning what right-to-left means, but go down toward the bottom and also sknake attached a project that demonstrates the label expansion.

DdoubleD 315 Posting Shark

OK, I ran this code on my XP laptop and it did create the profile. However, when I went to look under documents and settings, the username I expected to see was cryptic looking (3 vertical rect chars?)--I don't know what you call those chars but you see them all the time if you open a binary file in notepad.

Anyway, take a look at it and let me know also if it worked and what's up with how it created my user's folder name as mentioned above. It is initiated by calling static method: WindowsLoadUserProfile.Test()

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Principal;

namespace ForumSolutions
{

    public class WindowsLoadUserProfile
    {
        /// 
        /// The LogonUser function attempts to log a user on to the local computer.
        /// 
        [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern bool LogonUser(String lpszUsername, String lpszDomain, IntPtr lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr hToken);

        /// 
        /// The DuplicateTokenEx function creates a new access token that duplicates an existing token. This function can create either a primary token or an impersonation token.
        /// 
        [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern bool DuplicateTokenEx(IntPtr hExistingToken, int dwDesiredAccess, ref SecurityAttributes lpTokenAttributes,
        int impersonationLevel, int tokenType, out IntPtr phNewToken);

        /// 
        /// The LoadUserProfile function loads the specified user's profile
        /// 
        [DllImport("userenv.dll", CharSet = CharSet.Auto, SetLastError = true)]
        private static extern bool LoadUserProfile(IntPtr hToken, ref ProfileInfo lpProfileInfo);

        /// 
        /// The UnloadUserProfile function unloads a user's profile that …
DdoubleD 315 Posting Shark

What OS are you testing that LoadUserProfile call on?

DdoubleD 315 Posting Shark

I'm not sure you can invoke the creation of the new user's profile without logging the user onto the system, which is when a new user's profile gets created (logging in for the first time).

Have you tried LogonUser (advapi32.dll) and Impersonation? See: Windows Impersonation. I have my doubts, but if you have not tried it yet you might give it shot.

DdoubleD 315 Posting Shark

Not sure why your datagridview doesn't always have an unpopulated record shown. Check this code. As soon as you type anything in a cell, it will append a new unpopulated record/row to the end of the grid, which will again repeat as soon as you type anything in the new row...

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ForumSolutions
{
    public class Form_DataGridView_AddRow : Form
    {
        public Form_DataGridView_AddRow()
        {
            InitializeComponent();
        }

        private void dataGridView1_KeyPress(object sender, KeyPressEventArgs e)
        {

        }

        #region Designer generated code

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.dataGridView1 = new System.Windows.Forms.DataGridView();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
            this.SuspendLayout();
            // 
            // dataGridView1
            // 
            this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column1,
            this.Column2,
            this.Column3});
            this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.dataGridView1.Location = new System.Drawing.Point(0, 0);
            this.dataGridView1.Name = "dataGridView1";
            this.dataGridView1.Size = new System.Drawing.Size(489, 278);
            this.dataGridView1.TabIndex = 0;
            this.dataGridView1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.dataGridView1_KeyPress);
            // 
            // Column1
            // 
            this.Column1.HeaderText = "Column1";
            this.Column1.Name = "Column1";
            // 
            // Column2
            // 
            this.Column2.HeaderText = …
DdoubleD 315 Posting Shark

Maybe something useful in this information: System.DirectoryServices Using Guide

DdoubleD 315 Posting Shark

No one can compete with me in this field as sknake stated :)

At first I thought, "How arrogant." But, then I realized, it's true, "No one [wants to] compete with [him] in this field..." ;) Installers seem to be a lonely bunch. Anyway, I'm sure serkan will be glad to help you with ALL your install questions. Cheers!

DdoubleD 315 Posting Shark

That's how I originally started thinking it as an example, then I scrapped it figuring it wasn't practical for using the list, but don't really know exactly how it will be used anyway:

public class FieldValues
        {
            public int Row { get; set; }
            public string FldName { get; set; }
            public object FldRowValue { get; set; } // don't know its type yet

            public FieldValues(int row, string fldName, object value)
            {
                Row = row;
                FldName = fldName;
                FldRowValue = value;
            }
        }
        List<FieldValues> fieldValues = new List<FieldValues>();

        public void AddAnItem(int row, string fldName, object value)
        {
            fieldValues.Add(new FieldValues(row, fldName, value));
        }

DeOiD, be sure to check back periodically for some other's opinions too.

Cheers!

DdoubleD 315 Posting Shark
DdoubleD 315 Posting Shark

Right click on Setup project; choose View / User Interface

In UI, Right click on Start category, choose Add Dialog

In Add Dialog, double click on desired template (just select one if you have never done this before; easy to delete from your UI and then repeat to select a different one...practice doing this

In UI, select the dialog you added (or right click and choose properties). In the properties, this is where you customize the dialog.

I will try to locate a good link explaining this setup.

DdoubleD 315 Posting Shark

Here is an example of how you could build a dynamic table to hold your data. The field names and data types are up to you to decide, etc.:

public void BuildDynamicTableArrayExample()
        {
            DataTable dt = new DataTable(); // table to hold each record
            dt.Columns.Add(new DataColumn("FieldName1", typeof(string))); // Create a string column dynamically
            dt.Columns.Add(new DataColumn("FieldName2", typeof(int))); // create an int column dyn
            dt.Columns.Add(new DataColumn("FieldName3", typeof(double))); // create a double column dyn
            for (int r = 0; r < 10; r++) // generate 10 rows of data
            {
                DataRow dr = dt.NewRow();   // create a row object of table's type defined above

                dr["FieldName1"] = "data " + r; // add some data...
                dr["FieldName2"] = r;
                dr["FieldName3"] = (double)r;

                dt.Rows.Add(dr); // add the row to the table
            }
        }
DeOiD commented: very good example +3
DdoubleD 315 Posting Shark

oops, sorry. Try using: new SolidBrush(e.CellStyle.ForeColor) as the param.

DdoubleD 315 Posting Shark

I cannot tell from the code statements why you are getting the error. I suggest you zip up the project and attach.

serkan sendur commented: i agree +10
DdoubleD 315 Posting Shark

Maybe apply the current ForeColor ?:

e.Graphics.DrawString(Convert.ToString(e.FormattedValue), e.CellStyle.Font, e.CellStyle.ForeColor, e.CellBounds.X, e.CellBounds.Y - 2, StringFormat.GenericDefault)
DdoubleD 315 Posting Shark
// in Window1 button click
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Window2 window2 = new Window2();
            window2.Show();
            this.Close();
        }
DdoubleD 315 Posting Shark
// inside your UserControlGame (note I changed your array to begin with lowercase s char)
        Microsoft.VisualBasic.PowerPacks.OvalShape[] slotForm = new Microsoft.VisualBasic.PowerPacks.OvalShape[GlobalVariables.configsetup[0]];

        public Microsoft.VisualBasic.PowerPacks.OvalShape[] SlotForm
        {
            get
            {
                return slotForm; // returns ref to your array
            }
            set
            {
                slotForm = value; // sets your array to a new ref
            }
        }

// usage from within MindMasterColourForm class

        Microsoft.VisualBasic.PowerPacks.OvalShape ovalShape = ugc.SlotForm[i]; // access one of the array items...
DdoubleD 315 Posting Shark

Just use path.Split('\\', StringSplitOptions.RemoveEmptyEntries) .

This did not compile on my machine... so I modified it somewhat:

string path = "C:\\test\another\\directory\\";
            char[] charSeparators = { '\\' };
            string[] subPaths = path.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
DdoubleD 315 Posting Shark

thanks hope it works but ...I am getting Error : 'Image' is a 'namespace' but is used like a 'type' how to get rid of this ??

cya
Rohan

Which line gives you that error?

DdoubleD 315 Posting Shark

OK, I am really tired, but here is a quick fix for your needing to check the comboboxes to see if they have changed. This has been out here a few days and you probably need to get it fixed soon, right

string cbCheckIText, cbStartText, cbEndText;
        private void Configuration_Load(object sender, EventArgs e)
        {
            StreamReader fileread = File.OpenText("C:\\Documents and Settings\\tanfx\\Desktop\\Configuration\\Config.txt");
            {
                TBNewP.Clear();
                Text = fileread.ReadLine();
                CBStart.SelectedItem = cbStartText = fileread.ReadLine();
                Text = fileread.ReadLine();
                CBEnd.SelectedItem = cbEndText = fileread.ReadLine();
                Text = fileread.ReadLine();
                CBCheckI.SelectedItem = cbCheckIText = fileread.ReadLine();
                Text = fileread.ReadLine();
                TBImageL.Text = fileread.ReadLine();
                Text = fileread.ReadLine();
                TBDatabaseL.Text = fileread.ReadLine();
            }
        }

// then, where you do your checks:
        private void BTNCancel_Click(object sender, EventArgs e)
        {
            //Detect if there is changes in TBConfirmP||TBNewP||TBImageL||TBDatabaseL||CBCheckI||CBStart||CBEnd
            //Show Dialogue

            // COMMENT: I've never used this propery (Modified), but I'll assume it works...
            if ((TBConfirmP.Modified == true)|| (TBNewP.Modified == true)  || (TBImageL.Modified == true) || (TBDatabaseL.Modified == true) || //(CBCheckI)|| (CBStart) || (CBEnd)
                cbCheckIText != (string)CBCheckI.SelectedItem ||
                cbEndText != (string)CBEnd.SelectedItem ||
                cbStartText != (string)CBStart.SelectedItem)
            {
  ...

I think you will understand that. There are a number of ways to accomplish your goal, but as I said I am tired and you probably need to get it working so I hope this helps.

DdoubleD 315 Posting Shark

thanks for your help...but where should i give the path of the folder ?? or how to write it ?

List<Image> images = new List<Image>();
            DirectoryInfo di = new DirectoryInfo(@"c:\myimages"); // give path
            FileInfo[] finfos = di.GetFiles("*.jpg", SearchOption.TopDirectoryOnly);
            foreach (FileInfo fi in finfos)
                images.Add(Image.FromFile(fi.FullName));
DdoubleD 315 Posting Shark

Still missing definition for errorProvider1 object.. Is there another file I need to get this to compile?

DdoubleD 315 Posting Shark

I have not used a CrystalReportViewer control. I did try to replicate your issue with my project and database, but all I got was an empty view when I mimicked your code--no error, but no data either.

Can you zip up the project (include database)?

DdoubleD 315 Posting Shark

You need to post the designer code too: "Configuration.designer.cs" file.

Messy you say? I've seen much, much worse! No worries.

DdoubleD 315 Posting Shark

Post your code... Be sure to enclose in code tags.

DdoubleD 315 Posting Shark
public partial class Form1 : Form
    {
        int index = -1;
        List<Image> images;

        public Form1()
        {
            InitializeComponent();

            images = new List<Image>();
            // add images

        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            index++;
            if (index < 0 || index >= images.Count)
                index = 0;
            pictureBox1.Image = images[index];
        }
    }
DdoubleD 315 Posting Shark

Hi all,

Now i dont remember what we say about this method, i am so sorry for that anyway... I want to write in textbox when i am writing on it, it shows similar info to me. For example if i write dan it must be show daniweb, dance, danny, dan brown, ... this informations are in my database. i want to use this method in combobox, textbox, etc.
Thank you for your all atent.

Are you referring to autocomplete?

If so, check out this link: Adding autocomplete
Also: Another example and download

DdoubleD 315 Posting Shark

facadie, if you will post the code you thus far, I will help you. Please add comments to the code in the areas that you still have questions about too.

DdoubleD 315 Posting Shark

I'm not good at math either...LOL. Check out this thread, and see if you can come up with the formula you need. Then, if you need help with coding it, come on back here--OK?

Calculate Radius from X Y coord

DdoubleD 315 Posting Shark

Hey Danny, I played around with the example MSDN code for a little while this morning, tweaking here and there, and I couldn't find an easy way to make the existing code produce the desired behavior. I think what you would need to do to is override the default behavior of the DataGridViewTextBoxCell in the definition of:

public class CalendarCell : DataGridViewTextBoxCell

or, perhaps implement a customized version of: DataGridViewComboBoxCell that incorporates the DateTimePicker implementation and inherit from that instead.

I hope that someone will provide a reasonable solution, because I feel this is something that can be achieved without much overhead and I would like to see the necessary changes because I haven't spent much time with DataGridView's and am curious too.

In the MFC days, we would draw a combobox button in the cell right-justified and then monitor for a click in that region and produce the behavior that it was a combobox, or in your case, a DateTimePicker. However, things are simpler now and I just know someone will have a better suggestion to deal with this.

DdoubleD 315 Posting Shark

The title basically says it all.

How would I include a DLL for use in another project?

If I have understood your question, you need to add a reference to the assembly/library in your project. Under ProjectName/References, right click and select Add Reference; then select the Browse tab and go to the location of the DLL and select it.

DdoubleD 315 Posting Shark

Why does your data contain such escape sequences and why not scrub them out first before adding them if you need to display in a ListView control?

DdoubleD 315 Posting Shark

I had the same concerns you guys did about what was being done in his ListView--it seems like a futile exercise to me.

DdoubleD 315 Posting Shark

Your next loop should look like:

for (int lCount = 0; lCount < ListView1.Items.Count; lCount++)
                MessageBox.Show(ListView1.Items[lCount].Text)

to replace:

Dim lCount As Integer
            For lCount = 0 To ListView1.Items.Count
                MsgBox(ListView1.Items(lCount).Text)
            Next

NOTE: Not sure how VB handles declaration of iterator inside the loop ( lCount (maybe you can't), but in C# the variable lCount (as I demonstrated it) will no longer be in scope outside the confines of the loop block (single statement in this case).

DdoubleD 315 Posting Shark

You left off the parenthesis: lcount.ToString() should eliminate that error message.