从双链表中的编辑控件添加数据,然后在列表控件中输出 [英] Add data from Edit Control in double linked list and then output in List Control

查看:87
本文介绍了从双链表中的编辑控件添加数据,然后在列表控件中输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,我需要将编辑控件中插入的数据放入双喜欢列表中,然后打印列表控件中的所有条目。

我的老师告诉我处理数据一个结构(所以我不允许在一个类中执行此操作)。我把结构放在... Doc.h文件中。结构如下所示:

In my project i need to put the inserted data from an edit control in to a double liked list and then print all entries in a List Control.
My teacher told me to handle the data in a struct (so i'm not allowed to do this in a class). I put the struct in the ...Doc.h file. The struct looks like this:

typedef struct adr
{
    char anrede [5];
    char vorname [51];
    char nachname [51];
    char plz [8];
    char ort [60];
    char strasse [51];
    char land [24];
    char festnetz [14];
    char mobil [14];
    char mail [101];
    char geburtsdatum [11];
    char kategorie [31];
    char startnummer [5];
    char startzeit [9];
    char zeit [9];
    char rang [5];
    char fahrrad [31];
    char sponsor [31];
} adressen;

struct node
{
    adressen *konto;
    struct node *prev;
    struct node *next;
};



每个struct字段都有自己的编辑控件。编辑控件获得了有限的字符数。因此,您无法为结构字段插入许多字符。编辑控件的数据类型是CString,它们的名称如下:


Every struct field has its own edit control. The edit controls got a limited amount of character. So you cannot insert to many characters for the struct fields. The datatype of the edit controls is CString and they are named like:

m_anrede
m_vorname
m_nachname
m_plz
m_ort
m_strasse
m_land
m_festnetz
m_mobil
m_mail
m_geburtsdatum
m_kategorie
m_startnummer
m_startzeit
m_zeit
m_rang
m_fahrrad
m_sponsor



编辑控件放在由DlgAdd命名的对话框中。



现在我需要在双链表中的输入对话框中插入数据,该结构放在... Doc.h文件中然后打印列表控件中的所有条目,wole代码应该在View.cpp文件中。

我需要提示和技巧才能做到这一点,谢谢很多

推荐答案

你有一个很大的任务,需要它分成小任务。我的第一个建议是编写一些辅助函数来填充结构。喜欢

You have a big task, and need it to split in little tasks. My first advice, is to write some helper functions for filling the struct. Like
void setAnrede( adressen*data, const char* anrede ) {
  strncpy( data->anrede, anrede, 5 - 1 );//use maximal allowed space minus 1 (for the delimeter)
} 



这有助于避免出现问题,这非常值得花时间。



然后你需要使用这个教程来处理双链表。



对于对话问题,可以阅读本文: MFC中的对话数据交换并尝试代码。



我给你的建议是:OhneFleißkeinPreis。 ; - )


This helps avoiding problems and it is really worth the time.

Then you need to tackle double linked list with this tutorial.

For the dialog problems can should read this article: Dialog Data Exchange in MFC and try the code.

My advice to you: "Ohne Fleiß kein Preis." ;-)


根本不需要提示和技巧,只需将编辑控件中的值传递到 struct 的成员。您可以使用 GetWindowText [ ^ ]如果您的会员变量 CEdit 指针或直接复制字符串如果您的成员可变量 CString s。



请注意 C ++ struct 基本上 class es。唯一的区别是其成员的默认访问级别。
You don't need hint and trick at all, just a plain transfer of values from the edit controls to struct's member. You may use GetWindowText[^] if your member varaibles are CEdit pointers or directly copy the strings if your member varaiables are CStrings.

Please note C++ struct are basically classes. The only difference is the default access level of their members.


这篇关于从双链表中的编辑控件添加数据,然后在列表控件中输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆