Column Color change and DataGrid scrollbar

Hi,

1. I am working with a datagrid and i want one of the columns background color to   be red. How to achieve it. For eg; if i am having 15 columns, i want the 6th coloumn BGcolor to be in red at the time of form load event.

2. I want to access the datagrid's built in scrollbar. actually the scenario is
i am having 15 columns in the datagrid. The horizontal scroll bar should start from the 5 the column rather than from the first. so that the first 5 columns remains static and the balance columns scrolls.

it will b high helpful if provided with sample coding.
tu.






Answer this question

Column Color change and DataGrid scrollbar

  • Saranya

    ajay,

    If you have further questions on this issue, or other questions regarding the controls that are part of the System.Windows.Forms namespace, your best bet is to send your questions to one of the Windows Forms forums.
        http://forums.microsoft.com/msdn/default.aspx ForumGroupID=2

    I'd suggest posting to "Windows Forms Databinding", but you might want to try "Windows Forms General" as well.

    I hope this information proves helpful.

    David Sceppa
    Microsoft

  • JeremiahMetzen

    Hi,


    1. Here's a sample code to modify the cell background...
         DataGridViewCellStyle^ colStyle = gcnew DataGridViewCellStyle();
         colStyle->BackColor = Drawing::Color::Blue;
         dataGridViewTextBoxColumn1->DefaultCellStyle = colStyle;

    2. Just try to traverse the dataGridView1->Controls collection... you'll usually get 2 objects by default (VScrollBar and HScrollBar) Just cast it with the scrollbar object...

         IEnumerator^ i = dataGridView1->Controls->GetEnumerator();
         while (i->MoveNext()) {
          Control^ cur = static_cast<Control^>(i->Current);
          MessageBox:Tongue Tiedhow(cur->GetType()->ToString());
         }

    Hope this gets you started..


    cheers,


    Paul June A. Domag


  • Column Color change and DataGrid scrollbar