hi allata
If I only have this piece of data can i know the header Text of the datagridview column
//---------------------------
g.DrawString( TheDataGridView.Rows[CurrentRow].Cells[CurrentCell].EditedFormattedValue.ToString(), RowFont, RowForeBrush, CellBounds, CellFormat);
//-------------------------
tq
han
Loading
hanafi tanudjajaPosted Dec 22, 2009, 7:35 AM
,sorry to tell u that still not work,no error ,but no messagebox.arise
but never mind ,for this moment i use My own much more simple way but works
just to display the database, goods quantiy (JUMLAH=qty),and goods total quantity.
thank & regard
Nilanka DharmadasaPosted Dec 22, 2009, 4:44 AM
I got your problem. Add this code.
if (TheDataGridView.Rows[CurrentRow].Cells[CurrentCell].OwningColumn.HeaderText.Equals("JUMLAH"))
{
MessageBox.Show("Header=Jumlah");
}
Please tick 'Do you like this answer' checkbox if this helps you.
hanafi tanudjajaPosted Dec 22, 2009, 2:55 AM
I feel very sorry to make you busy
I also feel afraid to bother others by sending large file to this site ,so I think better to point the site
which launch the class:
it is in
http://www.codeproject.com/KB/printing/datagridviewprinter.aspx?msg=2279275#xx2279275xx
thank you & best regard
Nilanka DharmadasaPosted Dec 22, 2009, 2:05 AM
I'm sorry. Your code is still not clear for me. Can you upload your project? If it is too big, then at least paste or upload the code of the whole class.
Then I'll help you for sure.
hanafi tanudjajaPosted Dec 22, 2009, 1:08 AM
here is the snippet of code,I get it from ia site and try to make little change for my own need.
I suppose the iteration loop is from leftmost cell to the rightmost
thank you and nice regard
btw you have nice to hear name
//-----------------
for (int CurrentCell = (int)mColumnPoints[mColumnPoint].GetValue(0);
CurrentCell < (int)mColumnPoints[mColumnPoint].GetValue(1);
CurrentCell++)
{
// If the cell is belong to invisible
// column, then ignore this iteration
if (!TheDataGridView.Columns[CurrentCell].Visible) continue;
// Check the CurrentCell alignment
// and apply it to the CellFormat
if (TheDataGridView.Columns[CurrentCell].DefaultCellStyle.
Alignment.ToString().Contains("Right"))
CellFormat.Alignment = StringAlignment.Far;
else if (TheDataGridView.Columns[CurrentCell].DefaultCellStyle.
Alignment.ToString().Contains("Center"))
CellFormat.Alignment = StringAlignment.Center;
else
CellFormat.Alignment = StringAlignment.Near;
ColumnWidth = ColumnsWidth[CurrentCell];
RectangleF CellBounds = new RectangleF(CurrentX, CurrentY,
ColumnWidth, RowsHeight[CurrentRow]);
//int intx = TheDataGridView.CurrentCell.ColumnIndex;
//if (intx==1)
//{
// MessageBox.Show("1");
//}
g.DrawString(
TheDataGridView.Rows[CurrentRow].Cells[CurrentCell].
EditedFormattedValue.ToString(), RowFont, RowForeBrush,
CellBounds, CellFormat);
////// I put the addition in here ---------------------not " CITy" i am looking for but "JUMLAH" ////---------------
if (TheDataGridView.CurrentCell.OwningColumn.HeaderText == "JUMLAH")
{
MessageBox.Show("Header=Jumlah");
}
///////--------------------------------------------------
// Drawing the cell bounds
// Draw the cell border only
// if the CellBorderStyle is not None
if (TheDataGridView.CellBorderStyle !=
DataGridViewCellBorderStyle.None)
g.DrawRectangle(TheLinePen, CurrentX, CurrentY,
ColumnWidth, RowsHeight[CurrentRow]);
CurrentX += ColumnWidth;
}
//------------------------------------
Nilanka DharmadasaPosted Dec 21, 2009, 10:59 PM
where did you place thie code block. If you select a cell in city column you should get the message box.But for that, you should place this code block inside cellclick event of datagridview. If you can upload your code, I can correct it.
hanafi tanudjajaPosted Dec 21, 2009, 7:06 PM
Ihave tried your suggestion ,but still doesn work.
I insert
//--------------------------------
if ((TheDataGridView.CurrentCell.OwningColumn.HeaderText == "City")
{
MessageBox.Show("This is the column ");
}
//-----------------------------------
but no messageBox Shown ,the column with the header text "City" is available
thank you and regard
hanafi
Nilanka DharmadasaPosted Dec 21, 2009, 2:17 AM
Use following code.
if ((TheDataGridView.CurrentCell.OwningColumn.HeaderText == "City")
{
}
If you find my answer useful, please check 'Do you like this answer' checkbox.
hanafi tanudjajaPosted Dec 18, 2009, 8:56 PM
in my question context I have tried"
//-------------------------------------------------
if (TheDataGridView.Rows[CurrentRow].Cells[CurrentCell].Header.Text=="City")
{
}
and again
if (TheDataGridView.Rows[CurrentRow].Cells[CurrentCell].EditedFormattedValue.Header.Text=="City")
{
{
both of the are not working
any help ?
tg
}
//-----------------------------------------------
Sam HobbsPosted Dec 18, 2009, 11:38 AM