GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 03-Nov-2008, 07:32
almir almir is offline
New Member
 
Join Date: Oct 2008
Posts: 11
almir is on a distinguished road

StringGrid related questions


Hi all,
I have a couple of StringGrid related questions (within Borland environment). Maybe I should have asked them separately, but I guess that this is more efficient way. I do not expect one person to answer all of them, and I have plenty of time so whenever I get the answers I will be very thankful.

First question: What is the most efficient way to clear the contents of a StringGrid. At present I do a loop:

CPP / C++ / C Code:
for (int a=1;a<=stringGridX->RowCount-1;a++)
    stringGridX->Rows[a]->Clear();
    stringGridX->Refresh();


Is there some kind of function, like: stringGridx.Clear or Erase or so, which I obviously could not find?

Second question: I do the above code in a function called void clearGrid(); but it does not perform always? When I call it, it does not clear the grid...?

Third question: How do you print contents of a StringGrid in a plain, no specially formatted text on paper?

Fourth question: How do you save contents of a StringGrid in normal txt file format?

Fifth question: How do you get rid of the blue-highlighted first top left cell when the StringGrid shows for the first time on the screen?

thanks,

almir
  #2  
Old 03-Nov-2008, 08:37
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: StringGrid related questions


We could give you a better answer if we could see your code.
Make a small working example and post it.
  #3  
Old 05-Nov-2008, 05:29
almir almir is offline
New Member
 
Join Date: Oct 2008
Posts: 11
almir is on a distinguished road

Re: StringGrid related questions


Hi,
sorry for reacting to your reply a bit late but I wrestled with these for some time and the best code I could come up with - and it does not work, of course... - is for trying to save the contents of a StringGrid:

CPP / C++ / C Code:
void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString nameOfFile;
  if (SaveDialog1->Execute())
    {if (FileExists)
      {
        nameOfFile=SaveDialog1->FileName;
        if (RightStr(nameOfFile,4)==".txt")
        {
          StringGrid1->Rows->SaveToFile(SaveDialog1->FileName);
        }
        else
        {
          StringGrid1->Rows->SaveToFile(SaveDialog1->FileName+".txt");
        }
      }
    }
}

The compiler tells me that I have too few parameters calling Raws.

The other code, for printing the contents of a string grid I might infer if I have the upper code right, I guess.

The other code, for eliminating the blue highlight of a top left cell I really have no idea how it should look like...

regards,

almir
  #4  
Old 05-Nov-2008, 07:32
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 803
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: StringGrid related questions


This is NOT a small working example.... only a component. there is not even a 'Raws' in there.
We need to see how you declare and call everything.
Make something we can slap in and run and see the same behavior that you do. OK?
Do all the things in this TStringGrid tutorial work for you? sheepdogguides.com/dt2k.htm
I do not use Boland IDE and will not be able to play along... perhaps someone else does.
  #5  
Old 05-Nov-2008, 08:13
almir almir is offline
New Member
 
Join Date: Oct 2008
Posts: 11
almir is on a distinguished road

Re: StringGrid related questions


Here is all the code I have in the IDE:

CPP / C++ / C Code:
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
AnsiString truncateName;
  if (SaveDialog1->Execute())
    {if (FileExists)
      {
        truncateName=SaveDialog1->FileName;
        if (RightStr(truncateName,4)==".txt")
        {
          StringGrid1->Rows->SaveToFile(SaveDialog1->FileName);
        }
        else
        {
          StringGrid1->Rows->SaveToFile(SaveDialog1->FileName+".txt");
        }
      }
    }
}
//---------------------------------------------------------------------------

Besides that, there is one StringGrid on the form, one Save dialogue and a Button (which is supposed to save the file when clicked, but obviously does not work.)

The tutorial is useful - thanks!, and I already got some ideas, although not for the question above,

thanks,

almir
 
 

Recent GIDBlogAccepted for Ph.D. program by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple computer related questions Switch Computer Hardware Forum 7 21-Feb-2009 12:11
Looking for link exchange partners: webmaster related website metamorph Webmaster / Web Designing Advertisements & Offers 0 12-Nov-2007 01:22
List of programming related questions juvenile386 Miscellaneous Programming Forum 4 05-Jul-2007 08:49
Looking for site wide link exchange partners webmaster related PR6+ metamorph Webmaster / Web Designing Advertisements & Offers 0 30-Mar-2007 15:47
A few questions for someone in the programming industry. WAEvans Miscellaneous Programming Forum 0 08-Oct-2006 10:19

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 01:35.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.