Windows Develop Bookmark and Share   
 index > Windows Forms General > DataGridView in C#
 

DataGridView in C#

Here is an example of my code

private void OnListsCellClick(object sender, DataGridViewCellEventArgs e)

{

//This alows us to get data from the datagrid

DataGridViewCell cell = m_tab1dtgrdLists.Rows[e.RowIndex].Cells[e.ColumnIndex];

//Gets Data from Datagrid and but in members

strSelectedList = m_tab1dtgrdLists.CurrentRow.Cells[0].Value.ToString();

strListStarts = m_tab1lblListiStarts.Text = m_tab1dtgrdLists.CurrentRow.Cells[2].Value.ToString();

strListEnds = m_tab1lblListiEnds.Text = m_tab1dtgrdLists.CurrentRow.Cells[3].Value.ToString();

bWeeklist = m_tab1chckBxWeeklist.Checked = Convert.ToBoolean(m_tab1dtgrdLists.CurrentRow.Cells[4].Value);

}

The problem is when I hit the header of the grid because the header doesn’t contain any data.Firstthought hittest right? Well that needs a mouse event but the DataGridViewCell needs the DataGridViewCellEventArgs , so I can't just switch from cellclick to mousclick. So any ideas would be good... Really lost with this one

Gyða  Monday, March 19, 2007 4:50 PM
Figure it out don't have to use

DataGridViewCell cell = m_tab1dtgrdLists.Rows[e.RowIndex].Cells[e.ColumnIndex];

So I took it out so works :)

Gyða  Tuesday, March 20, 2007 12:28 AM
Figure it out don't have to use

DataGridViewCell cell = m_tab1dtgrdLists.Rows[e.RowIndex].Cells[e.ColumnIndex];

So I took it out so works :)

Gyða  Tuesday, March 20, 2007 12:28 AM

You can use google to search for other answers

Custom Search

More Threads

• UserControl in Toolbox
• Printing a Panel
• Adding dynamic watermark to files before print
• TextBoxBase.Lines - can you set them?
• Settings: Select a Type Dialog Box
• Bindable RadioButton List/Group UserControl in C#
• custom word-processor like control
• Using one Sub to visit multiple links
• What is a Dat file? In the binary writer context
• Create a new <appSettings> element in an app.Config file in vb.net?