如何在MFC应用程序的其中一列中生成序列号 [英] How do I generate serial number in one of the columns of MFC application

查看:110
本文介绍了如何在MFC应用程序的其中一列中生成序列号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试在序列号列中生成序列号,但我不知道应该在哪里放置该代码。因为我已经使用序列号,设备列表等字段制作了表格,但我需要序列号才能拥有自然数字,例如每个新行都会有唯一的序列号。

我无能为力如何解释你更多,所以请告诉我abhijith.v@somaiya.edu以便我可以与你分享我的工作



我尝试过:



我尝试在所有列的末尾添加生成数字的常规代码。像往常一样没有任何问题。我对这个MFC很新,所以请帮助我,我需要尽早提交这个

I have been trying to generate serial number in Serial number column but I have no clue where should i put that code. As in i have made the table with fields like serial number, device list , etc but i need serial number to have natural numbers for example every new row will have unique serial number.
I am clueless how to explain you more so please ping me on abhijith.v@somaiya.edu so that i can share my work with you

What I have tried:

I have tried putting the normal code for generating numbers at the end of all the columns. As usual nothing is working out.Iam new to this MFC so please help me i need to submit this as early as possible

推荐答案

目前还不清楚你的意思是,但是如果你需要一些序列号,那么你需要一个清晰的界面或功能来保证其唯一性。为此你必须保存最后给出的序列号。



元代码(为了简单起见,可以是字符串或对象)



It is not clear want you mean, but if you need some serial number, than you need a clear interface or function for that which garantues its uniqueness. For that you must savely store the last given serial number.

Meta-code (for simplicity an int, could be string or object)

int getSerialNumber()
{
  //get from persistent store like registry, web-service or disk
  int lastSerial = getLastSerial();
  //get the next, simplest way is +1
  int nextSerial = computeNextSerial( lastSerial );

  //save in persistent store
  saveLastSerial( nextSerial );

  return nextSerial;
}


这篇关于如何在MFC应用程序的其中一列中生成序列号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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