Click here to Skip to main content
15,881,875 members
Home / Discussions / C#
   

C#

 
GeneralRe: Best release management for winform project Pin
OriginalGriff8-Jan-21 8:45
mveOriginalGriff8-Jan-21 8:45 
GeneralRe: Best release management for winform project Pin
Mou_kol8-Jan-21 9:33
Mou_kol8-Jan-21 9:33 
GeneralRe: Best release management for winform project Pin
Mycroft Holmes8-Jan-21 11:37
professionalMycroft Holmes8-Jan-21 11:37 
QuestionHow to save DataGridView cell and text color? Pin
Alex Dunlop7-Jan-21 6:46
Alex Dunlop7-Jan-21 6:46 
AnswerRe: How to save DataGridView cell and text color? Pin
OriginalGriff7-Jan-21 7:49
mveOriginalGriff7-Jan-21 7:49 
GeneralRe: How to save DataGridView cell and text color? Pin
Alex Dunlop7-Jan-21 7:52
Alex Dunlop7-Jan-21 7:52 
GeneralRe: How to save DataGridView cell and text color? Pin
OriginalGriff7-Jan-21 8:22
mveOriginalGriff7-Jan-21 8:22 
GeneralRe: How to save DataGridView cell and text color? Pin
Alex Dunlop12-Jan-21 5:58
Alex Dunlop12-Jan-21 5:58 
I tried to build a Write/Read class as follows:
C#
 class DataGridViewColor
{
    public static void WriteDataGridViewSettings(System.Windows.Forms.DataGridView dgv)
    {
        XmlTextWriter writer = new XmlTextWriter(Application.StartupPath + @"\MyGridColor.xml", null);
        writer.WriteStartDocument();
        writer.WriteStartElement(dgv.Name);
        int LastRow = dgv.Rows.Count-1;
        for (int i = 0; i < LastRow; i++)
        {
            for (int j = 0; j < dgv.Columns.Count - 1; j++)
            {
                writer.WriteStartElement("Color");
                writer.WriteStartElement("CellColor");
                writer.WriteString(dgv.Rows[i].Cells[j].Style.BackColor.ToString());
                writer.WriteEndElement();
                writer.WriteStartElement("TextColor");
                writer.WriteString(dgv.Rows[i].Cells[j].Style.ForeColor.ToString());
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
        }
        writer.WriteEndElement();
        writer.WriteEndDocument();
        writer.Close();
    }


}

Now, I need to build a class for reading but I don't know how to do that.
Please guide me by giving a code so I can learn something about the solution.
I tried this code but it gives error:
C#
  class DataGridViewColor
{
    public static void ReadDataGridViewSettings(System.Windows.Forms.DataGridView dgv)
    {
        XmlDocument xmldoc = new XmlDocument();
        XmlNodeList xmlnode;
        FileStream fs = new FileStream(Application.StartupPath + @"\MyGridColor.xml", FileMode.Open, FileAccess.Read);
        xmldoc.Load(fs);
        xmlnode = xmldoc.GetElementsByTagName("column");
       for (int i = 0; i <= (xmlnode.Count)/13; i++)
            {
                string cellcolor = xmlnode[i].ChildNodes.Item(0).InnerText.Trim();
                string textcolor = xmlnode[i].ChildNodes.Item(1).InnerText.Trim();
                for (int j = 0; j < 13; j++)
                {
                    dgv.Rows[i].Cells[j].Style = new DataGridViewCellStyle {BackColor = Color.FromName(cellcolor)};
                    dgv.Rows[i].Cells[j].Style = new DataGridViewCellStyle {ForeColor = Color.FromName(textcolor)};
                }
            }
        fs.Close();
    }

}


modified 12-Jan-21 13:12pm.

Questionretrieve the date selected on a calendar control scheduler in C # Pin
Member 150371265-Jan-21 4:14
Member 150371265-Jan-21 4:14 
AnswerRe: retrieve the date selected on a calendar control scheduler in C # Pin
OriginalGriff5-Jan-21 6:44
mveOriginalGriff5-Jan-21 6:44 
AnswerRe: retrieve the date selected on a calendar control scheduler in C # Pin
Ralf Meier6-Jan-21 22:31
mveRalf Meier6-Jan-21 22:31 
QuestionSending Multiple Files in a single Request to API Pin
brown715764-Jan-21 6:49
brown715764-Jan-21 6:49 
AnswerRe: Sending Multiple Files in a single Request to API Pin
Richard Deeming4-Jan-21 22:19
mveRichard Deeming4-Jan-21 22:19 
Questioncode C# pour recuperer la date correspondante lorsqu'on clique sur une cellule Pin
Member 150371264-Jan-21 6:25
Member 150371264-Jan-21 6:25 
AnswerRe: code C# pour recuperer la date correspondante lorsqu'on clique sur une cellule Pin
Dave Kreskowiak4-Jan-21 6:37
mveDave Kreskowiak4-Jan-21 6:37 
AnswerRe: code C# pour recuperer la date correspondante lorsqu'on clique sur une cellule Pin
OriginalGriff4-Jan-21 8:28
mveOriginalGriff4-Jan-21 8:28 
QuestionWhat is the way to connect and stream IP camera Pin
Member 133273664-Jan-21 0:28
Member 133273664-Jan-21 0:28 
AnswerRe: What is the way to connect and stream IP camera Pin
Richard MacCutchan4-Jan-21 0:31
mveRichard MacCutchan4-Jan-21 0:31 
GeneralRe: What is the way to connect and stream IP camera Pin
Member 133273664-Jan-21 0:56
Member 133273664-Jan-21 0:56 
AnswerRe: What is the way to connect and stream IP camera Pin
OriginalGriff4-Jan-21 0:31
mveOriginalGriff4-Jan-21 0:31 
GeneralRe: What is the way to connect and stream IP camera Pin
Member 133273664-Jan-21 0:58
Member 133273664-Jan-21 0:58 
AnswerRe: What is the way to connect and stream IP camera Pin
RickZeeland4-Jan-21 0:40
mveRickZeeland4-Jan-21 0:40 
QuestionUsing 4D linked List make a Full functional Noted Pad on Winform Pin
Member 150308153-Jan-21 12:39
Member 150308153-Jan-21 12:39 
AnswerRe: Using 4D linked List make a Full functional Noted Pad on Winform Pin
OriginalGriff3-Jan-21 20:22
mveOriginalGriff3-Jan-21 20:22 
GeneralRe: Using 4D linked List make a Full functional Noted Pad on Winform Pin
Member 150308154-Jan-21 4:37
Member 150308154-Jan-21 4:37 

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.