|
Something went badly wrong there. Here it is:
ExportLineRow newRow = new ExportLineRow();
newRow.ExportLine = newLIne;
newRow.CreateCells(dgvLayout);
dgvLayout.Rows.Add(newRow);
int cx = 1;
foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
{
int rowIndex = dgvLayout.Rows.Count - 1;
dgvLayout.Rows[rowIndex].Cells[cx].Value = o.ColumnValue;
cx++;
}
|
|
|
|
|
my guess is nothing is wrong with rowIndex, but cx exceeds the Cells array because it
started at 1. Catch the exception, look at the line numbers in it, and tell Visual Studio
to always show line numbers (menu Tools/Options/TextEditor/...) so see exactly what line is
failing.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
cx starts at 1 because the is always a default column at the leftmost side of the grid. The line that is failing is:
newRow.Cells[cx].Value = o.ColumnValue;
I have checked and the number of columns is large enough. Using the same cx in the following line works fine.
dgvLayout.Rows[rowIndex].Cells[cx].Value = o.ColumnValue;
|
|
|
|
|
doesn't foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
iterate over ALL the columns, hence one more is bound to exceed the largest acceptable index?
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Both cases, the one commented out that doesn't work, and the one not commented out, are inside the same foreach loop, so my column indexing is not the problem. In other words, this works:
foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
{
int rowIndex = dgvLayout.Rows.Count - 1;
dgvLayout.Rows[rowIndex].Cells[cx].Value = o.ColumnValue;
cx++;
}
while this doesn't work:
foreach (Column o in newRow.ExportLine.RecordLayout.Columns.Values)
{
DataGridViewCell c = newRow.Cells[cx];
newRow.Cells[cx].Value = o.ColumnValue;
cx++;
}
|
|
|
|
|
if a simple guess doesn't help, establish the facts:
what does "doesn't work" mean?
what is the exact exception?
it goes wrong in exactly which line?
what is the value of the bad index?
what are the acceptable values of the index?
is newRow.ExportLine.RecordLayout.Columns.Values.Count equal to newRow.Cells.Count? check it!
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
1, 2, & 3. It throws an exception on the line I highlighted in an earlier post on this thread:
newRow.Cells[cx].Value = o.ColumnValue;
Specified argument was out of the range of valid values.
Parameter name: <big>rowIndex</big>
cx = 1
newRow.Cells.Count = 14
newRow.IsNewRow = true [Maybe this is my problem]
QuickWatch: newRow {DataGridViewRow { Index=-1 }} LayoutEditor.ExportLineRow
|
|
|
|
|
Brady Kelly wrote: on the line I highlighted
Haven't seen anything highlighted in your past five messages. I give up.
Read my tips, especially #2.
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
Luc Pattyn wrote: Haven't seen anything highlighted in your past five messages. I give up.
Read my tips, especially #2.
I wrote earlier: cx starts at 1 because the is always a default column at the leftmost side of the grid. The line that is failing is:
newRow.Cells[cx].Value = o.ColumnValue;
Thanks Luc, you have really made an effort , but the problem is clearly with the rowIndex being -1. I have checked everything else down to the bone, just short of debugging...Oooh, I can step into the source now! Now, where was that .NET source?
|
|
|
|
|
HI fri,
Iam looking code to take back up (MS Access database)...
Please help me fri....... if any 1 knows
My mail ID Pravinms07@yahoo.co.in
M.S.Praveen
|
|
|
|
|
Hi,
In regards to your query I would suggest you to visit the below mentioned link:
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=2406&lngWId=10[^]
This small application backs up a selected Access database. The application helps in taking backup of copies from each day that didn't have to be restored from a backup tape. The application implements FileStreams, TextWriter (for logging), use of a Timer component, etc, and the System.IO namespace in general.
I hope this will give some ideas how you can achive the desired result in your application.
Have a nice day .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi,
i want to set the Form widht and height accordig to my UserControl width and height at runtime? how can i do this?
have some sort of usefull weblink or code snippet.
best regards
|
|
|
|
|
myform.height = myusercontrol.height
myform.width = myusercontrol.width
I must not know what you are asking for since I would guess you could figure that out for yourself.
led mike
|
|
|
|
|
or if you need room for a border:
myform.ClientSize = new Size(myusercontrol.width+some, myusercontrol.height+some);
Luc Pattyn [Forum Guidelines] [My Articles]
This month's tips:
- before you ask a question here, search CodeProject, then Google;
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get;
- use PRE tags to preserve formatting when showing multi-line code snippets.
|
|
|
|
|
|
|
Don't cross post, it's considered rude
|
|
|
|
|
Hi freinds i want to develop crystal report which used different data source to dispaly different record in one singal report
There i have some Question
1 : Can i used Subreport for differnt datasource in main Crystal report and can i send parameter to them
2: can i useHide subreport i.e if i there is Condition to show subreport(a)
then all remain subreport shoul be hide mean to say shoe singal subreport in each case Can i do this Can some body tell me
wasim khan
|
|
|
|
|
Hi freinds i want to develop crystal report which used different data source to dispaly different record in one singal report
There i have some Question
1 : Can i used Subreport for differnt datasource in main Crystal report and can i send parameter to them
2: can i useHide subreport i.e if i there is Condition to show subreport(a)
then all remain subreport shoul be hide mean to say shoe singal subreport in each case Can i do this Can some body tell me
|
|
|
|
|
HI,
i have a windows application in c#2.0.
i have three Usercontrols and one c#2.0 Winform.i dont know how to capture the event in winforms that is generated on UserControl.
How Can i Capture the Controls Events in Winfrom that i put on my UserControl? send me some Usefull web link or code snippets
BestRegards
|
|
|
|
|
Hi,
I am using dataset to bind to a datagridview. Data set have
Id,Name,Date,UserID ,UserName columns. The datagridview I have
column autogenerate property false and added ID,Name,UserName columns added
at design time.
Now question is, when I add a new row in datagridview, after entering value
for Name column, when i hit Enter Key, it shows me error that UserID can not
be null.
Could some one give me idea how to populate UserID value if its not
displayed on the datagridview.
Please guide me how to solve above problem.
Thanks in advance.
Obalesu
|
|
|
|
|
Hi i'm new to programming and I am coding in Visual C++ using windows forms but don't know how to call code in form1.h from another class.
I want the user to click on a button which will then will execute my code from the other class.
The form1.h does not like you to include any of the header file I have created and I don't know they are meant to be included somewhere else. I have included them in class where the main is created.
Not sure the other way as well, so if I created a new .cpp file and need to use say a textbox in the code. What needs to be done for this to happen?
Sorry for the stupid question
modified on Friday, January 18, 2008 11:33:45 AM
|
|
|
|
|
I see you post has been sitting unanswered for awhile. I would suggest you could get an answer if you asked it in the Managed C++ forum as most developers here are C# coders.
You also do not indicate if your other code is in another form or not. Typically you do not treat a form as a class. If you have code to be executed in two locations, then you create a class library and have both the form and your other code consume that class library with the shared code.
If your method needs to operate on a textbox, then just make it a parameter into the method call.
Hope this helps you some.
|
|
|
|
|
Hi I'm looking for a time line editor component, much like how Adobe Premier or those time line editing music tools. Is there such one around to recommend?
|
|
|
|
|
I have a dialog form which is currently showing. I would like to temporarily make it invisible. If I either call Hide(), or send a message to it to hide, then it returns a DialogResult. I'd like it to stay in the dialog loop - I'm going to make it visible again later.
Anybody have any advice?
Best wishes
James
|
|
|
|