Click here to Skip to main content
15,920,632 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Exit For in C#? Pin
Hendrik Debedts1-Feb-07 6:51
Hendrik 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
led 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
mvePIEBALDconsult2-Feb-07 8:34 
QuestionDoes anyone know how to deploy the MMC Snapin project ? Pin
Glen Liu1-Feb-07 5:41
Glen Liu1-Feb-07 5:41 
QuestionHelp using DataGrid Pin
ricecake1-Feb-07 5:07
ricecake1-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:
C++
/* 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
ricecake20-Feb-07 11:11 
Questioniextenderprovider Pin
nileshkolnoorkar1-Feb-07 1:53
nileshkolnoorkar1-Feb-07 1:53 
Question.NET 2005 project build number Pin
MayyMagdy1-Feb-07 1:33
MayyMagdy1-Feb-07 1:33 
AnswerRe: .NET 2005 project build number Pin
ednrgc12-Feb-07 5:06
ednrgc12-Feb-07 5:06 
QuestionCScrollView equivalent Pin
hairy_hats1-Feb-07 0:08
hairy_hats1-Feb-07 0:08 
QuestionImplement Explicit Interface? Pin
Captain See Sharp31-Jan-07 15:45
Captain See Sharp31-Jan-07 15:45 
AnswerRe: Implement Explicit Interface? Pin
PIEBALDconsult1-Feb-07 7:40
mvePIEBALDconsult1-Feb-07 7:40 
GeneralRe: Implement Explicit Interface? Pin
Captain See Sharp1-Feb-07 8:26
Captain See Sharp1-Feb-07 8:26 
AnswerRe: Implement Explicit Interface? Pin
Guffa1-Feb-07 9:09
Guffa1-Feb-07 9:09 
GeneralRe: Implement Explicit Interface? Pin
Captain See Sharp1-Feb-07 9:18
Captain See Sharp1-Feb-07 9:18 
AnswerRe: Implement Explicit Interface? Pin
Guffa1-Feb-07 10:02
Guffa1-Feb-07 10:02 
GeneralRe: Implement Explicit Interface? [modified] Pin
Captain See Sharp1-Feb-07 11:12
Captain See Sharp1-Feb-07 11:12 
QuestionFormatting problem in SmtpClient Pin
sbpont31-Jan-07 8:40
sbpont31-Jan-07 8:40 
QuestionCollection in PropertyGrid Pin
VadimAn31-Jan-07 7:13
VadimAn31-Jan-07 7:13 
AnswerRe: Collection in PropertyGrid Pin
aSarafian1-Feb-07 2:59
aSarafian1-Feb-07 2:59 
GeneralRe: Collection in PropertyGrid Pin
VadimAn1-Feb-07 4:24
VadimAn1-Feb-07 4:24 
GeneralRe: Collection in PropertyGrid Pin
aSarafian1-Feb-07 9:24
aSarafian1-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.