我有一大堆C#代码应该在继承自UserControl的类中设置VerticalScroll.Value.当类的任何子对象改变大小时,它会被调用.该类的AutoScroll属性设置为true.
public void ScrollTo(int top)
{
if (top >= this.VerticalScroll.Minimum && top <= this.VerticalScroll.Maximum)
{
this.VerticalScroll.Value = top;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,在遍历代码时,有时会设置this.VerticalScroll.Value,有时它会保留调用此方法之前的值.
这是VS中的一个错误,还是存在值将忽略尝试设置它的已知条件?
谢谢,罗布
我们编写了一个Windows桌面应用程序,它安装在我们无法访问的几千台计算机上.当其中一个用户报告错误时,即使描述非常彻底,也有其他可能有用的信息.
我们目前正在开发自动反馈代理,这意味着我们可以访问非常详细的信息.但就像糖果店里的孩子一样,我们不知道从哪里开始. 您在同一案例的反馈包中会包含哪些信息? 有什么帮助我们重现那里的错误?
到目前为止我们得到的是:
请注意,这与此问题类似,但是当程序崩溃时,我们对获取信息并不感兴趣,就像用户遇到错误一样.
编辑:澄清:在发生错误的情况下,不询问用户应该提供哪些信息,而是我们应该以什么方式收集程序性信息呢?
这些问题是一种游戏,我没有找到适合他们的解决方案.
可以:::用C++ 编写而不使用引号或类似的东西,编译器也会接受它(宏也是禁止的).
C#也是如此,但在C#中,你必须写???.
我认为C++将使用::范围运算符而C#将使用? :,但我不知道它们的答案.
任何的想法?
我的iPad应用程序EXC_BAD_ACCESS在调用中遇到CGPDFContextClose以下方法中的消息.它只发生在某些页面上,并且目前只针对一个文档(不幸的是,这恰好是我们的帮助文档).
- (CGPDFDocumentRef)newSinglePageDocumentFromDocument:(CGPDFDocumentRef)document page:(NSInteger)pageNumber
{
CGPDFDocumentRef sourceDocument = CGPDFDocumentRetain(document);
CGPDFDocumentRef newDocument = NULL;
CFMutableDataRef consumerData = CFDataCreateMutable(kCFAllocatorDefault, 0);
CGDataConsumerRef contextConsumer = CGDataConsumerCreateWithCFData(consumerData);
CGPDFPageRef page = CGPDFDocumentGetPage(sourceDocument, pageNumber);
const CGRect mediaBox = CGPDFPageGetBoxRect(page, kCGPDFCropBox);
CGContextRef ctx = CGPDFContextCreate(contextConsumer, &mediaBox, NULL);
if (ctx)
{
if (page)
{
CGPDFContextBeginPage(ctx, NULL);
CGContextDrawPDFPage(ctx, page);
CGPDFContextEndPage(ctx);
}
//EXC_BAD_ACCESS thrown here
CGPDFContextClose(ctx);
CGContextRelease(ctx);
CGDataProviderRef provider = CGDataProviderCreateWithCFData((CFDataRef)consumerData);
newDocument = CGPDFDocumentCreateWithProvider(provider);
CGDataProviderRelease(provider);
}
CGDataConsumerRelease(contextConsumer);
CFRelease(consumerData);
CGPDFDocumentRelease(sourceDocument);
return newDocument;
}
Run Code Online (Sandbox Code Playgroud)
失败的文档可以通过Mac上的预览打开.我无法直观地识别失败的页面和成功的页面之间的任何区别.
任何人都可以看到代码有什么问题,或者发现问题的建议?
编辑:EXC_BAD_ACCESS在CGPDFContextClose方法中引发,见下文:
0x00e93d0e <+0000> …Run Code Online (Sandbox Code Playgroud) 我继承了一些iOS代码,它打开源PDF并创建一个CGContextRef从源文档中绘制单个页面的代码.问题是,某些文档有一个文档,遗憾的是我们的帮助文档导致此代码崩溃.
最终目标是一次缓存8个页面以改善用户体验.
CFMutableDataRef consumerData = CFDataCreateMutable(kCFAllocatorDefault, 0);
CGDataConsumerRef contextConsumer = CGDataConsumerCreateWithCFData(consumerData);
CGPDFPageRef page = CGPDFDocumentGetPage(sourceDocument, pageNumber);
const CGRect mediaBox = CGPDFPageGetBoxRect(page, kCGPDFCropBox);
CGContextRef pdfOutContext = CGPDFContextCreate(contextConsumer, &mediaBox, NULL);
CGContextDrawPDFPage(pdfOutContext, page); //If I comment out this line, no exception occurs
CGPDFPageRelease(page);
CGPDFContextEndPage(pdfOutContext);
CGPDFContextClose(pdfOutContext); //EXC_BAD_ACCESS
CGContextRelease(pdfOutContext);
Run Code Online (Sandbox Code Playgroud)
(这是代码的简化版本,原来打开一个源文件和一个网页,检查对空page和ctx,然后写入ctx到一个新的文件.)
如果不是绘制到PDF上下文,而是绘制到如此创建的UIGraphics上下文,那就没有问题了:
CGContextRef graphicsContext = UIGraphicsGetCurrentContext();
当我在PDF上下文中绘制其他内容时也没有问题.
此外,这适用于99%的文档和违规文档中75%的页面.违规文档在多个PDF查看器中正确呈现.
所以我认为我不会有内存问题.我相信CGPDF代码中有一些东西是错误的(我说只有花了一个星期才试图解决这个问题).
我的问题是,还有其他方式我应该/可以这样做吗?
如果我有一对日期,并且我想生成它们之间所有日期的列表(包括),我可以执行以下操作:
System.DateTime s = new System.DateTime(2010, 06, 05);
System.DateTime e = new System.DateTime(2010, 06, 09);
var list = Enumerable.Range(0, (e - s).Days)
.Select(value => s.AddDays(value));
Run Code Online (Sandbox Code Playgroud)
我坚持的是,我有一个日期对的列表,我想要将它们分解为它们之间所有日期的列表.例:
{2010-05-06, 2010-05-09}, {2010-05-12, 2010-05-15}
Run Code Online (Sandbox Code Playgroud)
应该导致
{2010-05-06, 2010-05-07, 2010-05-08, 2010-05-09, 2010-05-12, 2010-05-13, 2010-05-14, 2010-05-15}
Run Code Online (Sandbox Code Playgroud)
请注意,保证日期对不会相互重叠.
取两个基类A和B,它们相似但最好是不同的.每个子类都有一个子类(A'和B'),它们将相同的功能和成员添加到它们各自的类中.是否有设计模式允许我不必重复A'和B'中的代码?
我看Bridge和Decorator,但我看不出这是可行的.
谢谢,罗布
在Visual Studio(C#)中设计应用程序时,如果我知道我将拥有一定数量的DataGridViews,它们都具有相同的属性(如宽度,高度,颜色,其他一些属性,如:禁用直接编辑行的选项等)是否可以创建我自己的类("myDataGridView")继承DataGridView类并在那里进行所有调整,然后在代码中稍后实例化该类?像这样:
//my class:
class myDataGridView : DataGridView
{
this.BorderStyle = <someValue>
this.ColumnCount = <someValue>
//etc.
public void method1()
{
//some code...
}
public void method2()
{
//some code...
}
}
//instantiate it somewhere:
myDataGridView dgv1 = new myDataGridView();
myDataGridView dgv2 = new myDataGridView();
myDataGridView dgv3 = new myDataGridView();
Run Code Online (Sandbox Code Playgroud)
OO原则是否可以?我的朋友说把代码放进去了
this.BorderStyle = <someValue>
Run Code Online (Sandbox Code Playgroud)
在myDataGridView类中是不好的做法,因为如果你知道我的意思,调整像这样的属性会溢出dataGridView的属性,其他开发人员可能会在Visual Studio中直观调整.那有关系吗?我的意思是,如果我想将我的DataGridView视为一个对象,那么它可以具有其属性和行为,对吧?并且在我的类中使用调整DataGridView属性的代码是可以的,可读的,并且每个想要更改某些属性的开发人员都可以在myDataGridView类中更改它.这种做法是坏还是错?如果是,当您知道您的应用程序将具有许多具有相同属性/行为的DataGridView时,最佳做法是什么?谢谢.
我正在使用模板创建自己的字典(不,我不能,我不会使用STL中的任何内容).
我想要一个非常简单的搜索功能,但我有一个小问题.
template <typename TElement>
void Dictionary<TElement>::search(TElement ADT, int key) { // Abstract Data Type
inf flag = 0;
index = int (key % max);
temp[index] = root[index]; // root of the hash
while (temp[index]->next != NULL) {
if(temp[index]->data->key_actual_name == key) { @things happen }
}
}
Run Code Online (Sandbox Code Playgroud)
我想要了解的内容:如何使用模板,以便我可以拥有,temp[index]->data-><template call>如果这是有道理的
我想通过使用来调用字典:Class_type == TElement和"key"总是一个int但它可以是不同的东西.它可能是ID或电话号码.问题是我需要使用密钥的实际名称(if(temp[index]->data->ID (or phone or what ever) == key){@things happen}),我想我可以在这里使用模板,但我不知道如何.
也许相关:
template <typename TElement>
typedef struct list{
TElement data;
struct list *next;
}node_type; …Run Code Online (Sandbox Code Playgroud) 嘿,我有这种形式
<form method="POST" action=''>
<input type="hidden" name="op" value="download1">
<input type="hidden" name="usr_login" value="<TMPL_VAR usr_login>">
<input type="hidden" name="id" value="<TMPL_VAR file_code>">
<input type="hidden" name="fname" value="<TMPL_VAR file_name>">
<input type="hidden" name="referer" value="<TMPL_VAR referer>">
<div class="premium-download"><input name="method_premium" value="<TMPL_VAR lang_premium_download>" type="image" src="images/premium-download.png" alt="<TMPL_VAR lang_premium_download>" border="0" /></div>
<div class="free-download"><input name="method_free" value="<TMPL_VAR lang_free_download>" type="image" src="images/free-download.png" alt="<TMPL_VAR lang_free_download>" /></div>
</form>
Run Code Online (Sandbox Code Playgroud)
如何从图像输入提交表格(参见最后两个字段)?现在他们被设置为图像类型,我知道那些默认情况下不会提交表单.有人可以帮忙吗?有人告诉我用javascript做这件事:D
我有一个二进制文件.我不知道如何使用C#读取这个二进制文件.
C++中描述的二进制文件中记录的定义是:
#define SIZEOF_FILE(10*1024)
//Size of 1234.dat file is: 10480 + 32 byte (32 = size of file header)
typedef struct FileRecord
{
WCHAR ID[56];
WCHAR Name[56];
int Gender;
float Height;
WCHAR Telephne[56];
and........
}
Run Code Online (Sandbox Code Playgroud)
如何在C#中读取包含这些记录的二进制文件,并在编辑后将其写回?
main() {
unsigned int a=-9;
printf("%d",a);//gives output -9
cout<<a;// gives output 9429967287
getch();
}
Run Code Online (Sandbox Code Playgroud)
为什么它在两种情况下都提供不同的输出
'printf'和'cout'以不同的方式处理位模式吗?
为什么'printf'没有给出肯定答案?
public DataTable UserUpdateTempSettings(int install_id, int install_map_id, string Setting_value,string LogFile)
{
SqlConnection oConnection = new SqlConnection(sConnectionString);
DataSet oDataset = new DataSet();
DataTable oDatatable = new DataTable();
SqlDataAdapter MyDataAdapter = new SqlDataAdapter();
try
{
oConnection.Open();
cmd = new SqlCommand("SP_HOTDOC_PRINTTEMPLATE_PERMISSION", oConnection);
cmd.Parameters.Add(new SqlParameter ("@INSTALL_ID", install_id));
cmd.Parameters.Add(new SqlParameter ("@INSTALL_MAP_ID", install_map_id));
cmd.Parameters.Add(new SqlParameter("@SETTING_VALUE", Setting_value));
if (LogFile != "")
{
cmd.Parameters.Add(new SqlParameter("@LOGFILE",LogFile));
}
cmd.CommandType = CommandType.StoredProcedure;
MyDataAdapter.SelectCommand = cmd;
cmd.ExecuteNonQuery();
MyDataAdapter.Fill(oDataset);
oDatatable = oDataset.Tables[0];
return oDatatable;
}
catch (Exception ex)
{
Utils.ShowError(ex.Message);
return oDatatable;
}
finally …Run Code Online (Sandbox Code Playgroud) c# ×8
c++ ×3
objective-c ×2
binary-data ×1
c ×1
cgpdf ×1
cgpdfcontext ×1
controls ×1
datagridview ×1
dry ×1
exception ×1
forms ×1
html ×1
ipad ×1
javascript ×1
linq ×1
onclick ×1
oop ×1
pdf ×1
subclass ×1
syntax ×1
templates ×1
winforms ×1