Search Results

Search found 2 results on 1 pages for 'the demigeek'.

Page 1/1 | 1 

  • Operation can only be performed on cells that belong to a DataGridView control

    - by The Demigeek
    The following code throws an InvalidOperationException with the above message and I don't understand why. My code calls the following method when the user may have made changes to the datagridview's underlying data source. The goal is to update the display with any changed data, and preserve the sort column and order. private void ReloadDataGridBindingListFromDatabase() { DataGridView dgv = myDataGridViewControl; DataGridViewColumn sortedColumn = dgv.SortedColumn; SortOrder sortOrder = dgv.SortOrder; //do stuff here to refresh dgv.DataSource if (sortedColumn != null) { //this line throws an exception sortedColumn.HeaderCell.SortGlyphDirection = sortOrder; } //etc. } Clearly, sortedColumn.HeaderCell is a cell that belongs to a DataGridView control. So why am I getting this exception? Many thanks for your input.

    Read the article

  • Calling base Text method on custom TextBox

    - by The Demigeek
    I'm trying to create a CurrencyTextBox that inherits from TextBox. I'm seeing some really weird behavior that I just don't understand. After lots of testing, I think I can summarize as follows: In the class code, when I access base.Text (to get the textbox's text), I'm actually getting the return value of my overridden Text property. I thought the base keyword would ensure that the underlying object's methods get called. To demonstrate: public class cTestTextBox : System.Windows.Forms.TextBox { string strText = ""; public cTestTextBox() { SetVal("AAA"); base.Text = "TEST"; } public override string Text { get { string s = strText; s = "++" + s + "++"; return s; } } public void SetVal(string val) { strText = val; } } Place this control on a form and set a breakpoint on the constructor. Run the app. Hover your mouse over the base.Text expression. Note that the tooltip shows you the value of the overridden property, not the base property. Execute the SetVal() statement and again hover your mouse over the base.Text expression. Note that the tooltop shows you the value of the overridden property, not the base property. How do I reliably access the Text property of the textbox from which I'm inheriting?

    Read the article

1