|
for (int num = 0; num < treeList1.ViewInfo.RowsInfo.Rows.Count; num++)
{
}
All people for me query as a way that get the value of each line in TreeList, thanks.
|
|
|
|
|
Iterate the nodes; there's documentation here[^], and DevExpress has their own forum, specializing in their own products.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
What the use of this code:
foreach (TerminalGroup tg in vps) return tg;
Is there a benefit using this over something like:
if (vps.Length > 0) return vps[0]
I see this used more often, it's seems to be done deliberately.
|
|
|
|
|
I would suggest that the first version is lazy coding.
|
|
|
|
|
The first one also works when the collection is enumerable but has no indexer (though I don't really like that code even in that situation). Apart from that, AFAIK there's no point.
|
|
|
|
|
It's not some strange code trick that is a millisecond faster because it does less checks or so?
|
|
|
|
|
Depends on what the thing is.
For arrays, there is literally no difference. The assembly code generated by the JIT compiler is exactly the same, at least in my test case.
static int Test2(int[] array)
{
if (array.Length > 0)
return array[0];
throw new Exception();
}
static int Test1(int[] array)
{
foreach (int i in array)
return i;
throw new Exception();
}
push rbx
sub rsp,20h
mov rax,qword ptr [rcx+8]
test eax,eax
jle 0000000000000020
test rax,rax
jbe 0000000000000040
mov eax,dword ptr [rcx+10h]
add rsp,20h
pop rbx
ret
For other things, of course you can construct a type such that indexing is slow (always, also at index 0) and enumeration is fast, but usually starting to enumerate means setting up a little state machine (takes some non-zero but usually tiny amount of time) and indexing at index 0 is usually trivial.
TL;DR I would guesstimate that the second way is faster more often than it is slower.
|
|
|
|
|
Hello,
In my program I need to be checked if the database was deleted, the program creates it again. So, I made a database and connected it to my program with 'LINQ-To-SQL-Classes', when I delete the database manually ("Database1.mdf" and "Database1_log.ldf"), it cannot create the database and show me this error:
" Database 'C:\Users\Saleh\documents\visual studio 2010\Projects\St\St\bin\Debug\Database1.mdf' already exists. Choose a different database name. "
Here is my code:
private void button1_Click(object sender, EventArgs e)
{
string strDBPath = Application.StartupPath + ("\\Database1.mdf");
DataClasses1DataContext objDB = new DataClasses1DataContext(strDBPath);
if (!objDB.DatabaseExists())
{
objDB.CreateDatabase();
MessageBox.Show("Database created!");
}
}
How can I handle it?
Thanks in advance!
|
|
|
|
|
am placing interval value in app.config as
<add key="TCPIP" value="192.168.2.130"/>
<add key="tcpport" value="6000"/>
<add key="tcpadderss" value="FF"/>
<add key="comaddress" value="FF"/>
<add key="interval" value="200"/>
then now i want to assign that value to combobox in c#
textBox8.Text = System.Configuration.ConfigurationManager.AppSettings["TCPIP"];
textBox7.Text = System.Configuration.ConfigurationManager.AppSettings["tcpport"];
textBox9.Text = System.Configuration.ConfigurationManager.AppSettings["tcpadderss"];
Edit_CmdComAddr.Text = System.Configuration.ConfigurationManager.AppSettings["comaddress"];
comboBox1.SelectedItem= System.Configuration.ConfigurationManager.AppSettings["interval"];
in case of textboxes it's working fine. but how to assign interval value to combox.when i run the project form shoul load with that interval value
|
|
|
|
|
If for your combobox value and text both are same then you may use comboBox1.SelectedValue .
Regards,
CodeBlack
|
|
|
|
|
thanq i got it. but now the problem is
i run my application-->selected one radio button -->then closed m application.
if i run my application next time ,that form should be opened by selecting the previous radio button. i need to store those values in app.config .how to store them dynamically in app.config
-- modified 8-Nov-13 5:10am.
|
|
|
|
|
Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings["test"].Value = "blah";
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");
It was worked for me.
Don't forget to mark it as an answer.
Regards,
CodeBlack
|
|
|
|
|
sorry it's not working for me.how can i test ,whether it's working or not.
i kept that code in radiobutton_checkedChanged().and changed test-->tcpradio and blah-->true
in app.config
<appSettings>
<add key="tcpradio" value="0"/>
</appSettings>
plz help me
|
|
|
|
|
is it your windows application ?
Regards,
CodeBlack
|
|
|
|
|
yes it's windows application.vs2010 c# 4.0
|
|
|
|
|
Agreed on what Bernhard Hiller said. There are many options to achieve the same thing.
For example,
you can create a cookie and set value into cookie and define cookie expiration time Or
you can use the application data (AppData)folder. or
you can store it in database as well.
Store it in app.config only if there is no any other way.
Regards,
CodeBlack
|
|
|
|
|
If you want to change the values from your program, use settings - app.config is not the correct place for that.
|
|
|
|
|
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;
using OtherLibs;
using CxCore;
namespace oneMoreTry
{
public partial class Form1 : Form
{
private CvCapture VideoCapture;
private IplImage frame;
private IplImage imgMain;
bool capture = false;
public Form1()
{
InitializeComponent();
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
capture = true;
}
private void btnVideo_Click(object sender, EventArgs e)
{
double vidWidth, vidHeight;
VideoCapture = highgui.CvCreateCameraCapture(0);
if (btnVideo.Text.CompareTo("Start Video") == 0)
{
if (VideoCapture.ptr == IntPtr.Zero)
{
MessageBox.Show("badtrip ah!!!");
return;
}
btnVideo.Text = "Stop Video";
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH, 640);
highgui.CvSetCaptureProperty(ref VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT, 480);
highgui.CvQueryFrame(ref VideoCapture);
vidWidth = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_WIDTH);
vidHeight = highgui.cvGetCaptureProperty(VideoCapture, highgui.CV_CAP_PROP_FRAME_HEIGHT);
picBoxMain.Width = (int)vidWidth;
picBoxMain.Height = (int)vidHeight;
timerGrab.Interval = 42;
timerGrab.Enabled = true;
}
else
{
btnVideo.Text = "Start Video";
timerGrab.Enabled = false;
if (VideoCapture.ptr == IntPtr.Zero)
{
highgui.CvReleaseCapture(ref VideoCapture);
VideoCapture.ptr = IntPtr.Zero;
}
}
}
private void timerGrab_Tick(object sender, EventArgs e)
{
frame = highgui.CvQueryFrame(ref VideoCapture);
if (frame.ptr == IntPtr.Zero)
{
timerGrab.Stop();
MessageBox.Show("??");
return;
}
imgMain = cxcore.CvCreateImage(cxcore.CvGetSize(ref frame),8,3);
picBoxMain.Image = highgui.ToBitmap(imgMain, false);
cxcore.CvReleaseImage(ref imgMain);
}
}
}
I have this code and when i step through the debugger to find the problem.
The problem i encounter is like this, it says that Cannot evaluate expression because a native frame is on top of the call stack.
when i break the debugger. the program stops at this point of the code. frame = highgui.CvQueryFrame(ref VideoCapture);
i dont know how to or what to revised in the code.
|
|
|
|
|
Hit F10 to step to the next statement in your code, and close any dialog boxes that have been opened by your code, and you'll be able to evaluate expressions.
|
|
|
|
|
i do what you said. but it didn't do anything.
the output of the screen captured from the webcam is still black screen only.
|
|
|
|
|
You need to step back out of the native code so the debugger will work. Try Shift-F11 which will step back out of the code you're in. You may have to do it several times, but eventually you'll return to to debuggable code.
|
|
|
|
|
i also try it. but when it returns to that. it is still black screen..
|
|
|
|
|
It looks like you're stepping into code you can't step out of. I'd guess it's your video-capture utility.
So just set breakpoints in your code, and only step into your own methods.
|
|
|
|
|
hmm i think it is on my code. or in the DLL's that i used in the code?
because when i breakpoints on some.
there is an error that goes like this.
System.AccessViolationException
|
|
|
|
|
hi,
i need to write custom elements in app.config. how to write it.
am developing UHFReader project.in that we r having TCP/IP and COM commections.
So I need to place IP,Port,Address and Interval(time setting to run the timer).in configuration file. plz help me how to develop it. and how to access that in my project.
|
|
|
|