Click here to Skip to main content
14,876,655 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Exit For in C#? Pin
Hendrik Debedts1-Feb-07 6:51
MemberHendrik Debedts1-Feb-07 6:51 
GeneralRe: Exit For in C#? Pin
Pete O'Hanlon1-Feb-07 9:07
mvePete O'Hanlon1-Feb-07 9:07 
GeneralRe: Exit For in C#? Pin
led mike1-Feb-07 10:28
Memberled mike1-Feb-07 10:28 
GeneralRe: Exit For in C#? Pin
Alexandru Lungu2-Feb-07 6:09
professionalAlexandru Lungu2-Feb-07 6:09 
GeneralRe: Exit For in C#? Pin
Pete O'Hanlon2-Feb-07 8:32
mvePete O'Hanlon2-Feb-07 8:32 
GeneralRe: Exit For in C#? Pin
PIEBALDconsult2-Feb-07 8:34
professionalPIEBALDconsult2-Feb-07 8:34 
QuestionDoes anyone know how to deploy the MMC Snapin project ? Pin
Glen Liu1-Feb-07 5:41
MemberGlen Liu1-Feb-07 5:41 
QuestionHelp using DataGrid Pin
ricecake1-Feb-07 5:07
Memberricecake1-Feb-07 5:07 
In my application, I have a DataGrid that is used to display search results from a query into a Firebird SQL database. The DataGrid is not directly connected to the DB, but instead I perform my query and store the results in a std::vector, perform some more work on it, then copy the final results into an ArrayList that the DataGrid is connected to.

So, when I do a search, it goes like this:
/* Obtain final std::vector with query results */

/* search_results_list is an ArrayList */
search_results_list->Clear();

// copy data into ArrayList
tr = db_conn->BeginTransaction();
typedef vector<int>::const_iterator CIter;
for (CIter it = run_ids.begin(); it != run_ids.end(); ++it) {
    /* look up Run ID in DB and store the run in disp */
    search_results_list->Add(disp);
}
tr->Commit();

/* reset DataSource to refresh the display */
datagrid_search_results->DataSource = 0;
datagrid_search_results->DataSource = search_results_list;
This works fine the first time, however I am having the following problem. If I click on a row, then subsequently perform another search that makes the row disappear, I get an IndexOutOfRange exception:
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.Windows.Forms.DataGrid.Edit(String instantText)
at System.Windows.Forms.DataGrid.Edit()
at System.Windows.Forms.DataGrid.OnEnter(EventArgs e)
at System.Windows.Forms.Control.NotifyEnter()
at System.Windows.Forms.ContainerControl.UpdateFocusedControl()

However, my DataGrid has set the ReadOnly property to true. In my other DataGrid that is used for a different purpose, I was able to solve it by setting the CurrentSelectedRow property to 0 before removing the elements, but this does not work in this situation.

I am not sure if it is related to this, but the only event I am handling for this DataGrid is the MouseUp event, in order to get it to select the entire row when a cell is clicked:
// Select the entire row when the user clicks on a cell in the row
System::Void datagrid_MouseUp(System::Object* sender, System::Windows::Forms::MouseEventArgs* e)
{
    using System::Drawing::Point;
    using System::Windows::Forms::DataGrid;
    using System::Windows::Forms::DataGridCell;

    Point pt = Point(e->X, e->Y);
    DataGrid* datagrid = __try_cast<DataGrid*>(sender);
    DataGrid::HitTestInfo* hti = datagrid->HitTest(pt);
    if (hti->Type == DataGrid::HitTestType::Cell) {
        datagrid->CurrentCell = DataGridCell(hti->Row, hti->Column);
        datagrid->Select(hti->Row);
    }
}


--
Marcus Kwok

AnswerRe: Help using DataGrid Pin
ricecake20-Feb-07 11:11
Memberricecake20-Feb-07 11:11 
Questioniextenderprovider Pin
nileshkolnoorkar1-Feb-07 1:53
Membernileshkolnoorkar1-Feb-07 1:53 
Question.NET 2005 project build number Pin
MayyMagdy1-Feb-07 1:33
MemberMayyMagdy1-Feb-07 1:33 
AnswerRe: .NET 2005 project build number Pin
ednrgc12-Feb-07 5:06
Memberednrgc12-Feb-07 5:06 
QuestionCScrollView equivalent Pin
hairy_hats1-Feb-07 0:08
Memberhairy_hats1-Feb-07 0:08 
QuestionImplement Explicit Interface? Pin
Captain See Sharp31-Jan-07 15:45
MemberCaptain See Sharp31-Jan-07 15:45 
AnswerRe: Implement Explicit Interface? Pin
PIEBALDconsult1-Feb-07 7:40
professionalPIEBALDconsult1-Feb-07 7:40 
GeneralRe: Implement Explicit Interface? Pin
Captain See Sharp1-Feb-07 8:26
MemberCaptain See Sharp1-Feb-07 8:26 
AnswerRe: Implement Explicit Interface? Pin
Guffa1-Feb-07 9:09
MemberGuffa1-Feb-07 9:09 
GeneralRe: Implement Explicit Interface? Pin
Captain See Sharp1-Feb-07 9:18
MemberCaptain See Sharp1-Feb-07 9:18 
AnswerRe: Implement Explicit Interface? Pin
Guffa1-Feb-07 10:02
MemberGuffa1-Feb-07 10:02 
GeneralRe: Implement Explicit Interface? [modified] Pin
Captain See Sharp1-Feb-07 11:12
MemberCaptain See Sharp1-Feb-07 11:12 
QuestionFormatting problem in SmtpClient Pin
sbpont31-Jan-07 8:40
Membersbpont31-Jan-07 8:40 
QuestionCollection in PropertyGrid Pin
VadimAn31-Jan-07 7:13
MemberVadimAn31-Jan-07 7:13 
AnswerRe: Collection in PropertyGrid Pin
aSarafian1-Feb-07 2:59
MemberaSarafian1-Feb-07 2:59 
GeneralRe: Collection in PropertyGrid Pin
VadimAn1-Feb-07 4:24
MemberVadimAn1-Feb-07 4:24 
GeneralRe: Collection in PropertyGrid Pin
aSarafian1-Feb-07 9:24
MemberaSarafian1-Feb-07 9:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.