全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:3294
推到 Plurk!
推到 Facebook!

C++ Builder StringGrid輸入2字元後,如何自動跳到下一格

尚未結案
mgwu
一般會員


發表:2
回覆:1
積分:0
註冊:2003-04-18

發送簡訊給我
#1 引用回覆 回覆 發表時間:2005-10-11 12:28:18 IP:61.219.xxx.xxx 未訂閱
請問 C Builder StringGrid輸入2字元後,如何自動跳到下一格?
DavidLo
高階會員


發表:17
回覆:225
積分:168
註冊:2004-07-21

發送簡訊給我
#2 引用回覆 回覆 發表時間:2005-10-18 02:02:35 IP:218.169.xxx.xxx 未訂閱
Hi!    我提供我的方法:    
 
void __fastcall TFormTable::StringGrid1KeyPress(TObject *Sender, char &Key)
{
    if(Key==VK_ESCAPE)
        {
        ModalResult = mrOk;//跳出視窗
        }
//enter -> next row,you have to decide left or bottom cell
    else if(Key==VK_RETURN)
        {
        StringGrid1->Row  ;//next row same column
        //StringGrid1->Col  ;//next left column
        return;
        }        int col, row;        // limit input length
    col = StringGrid1->Col;
    row = StringGrid1->Row;
    switch(col)//不同Column,不同寬度限制
        {
        case 1:
            if(user_mode==2)
              {
              if(StringGrid1->Cells[col][row].Length()>=10)
                {
                Key = 0;
                FormMain->StatusBar1->SimpleText = "長度限制10!";
                Beep(1200,100);
                }
              }
            else
              {
              if(StringGrid1->Cells[col][row].Length()>=20)
                {
                Key = 0;
                FormMain->StatusBar1->SimpleText = "長度限制20!";
                Beep(1200,100);
                }
              }
            break;
        case 2:
            if(StringGrid1->Cells[col][row].Length()>=20)
              {
              Key = 0;
              FormMain->StatusBar1->SimpleText = "長度限制20!";
              Beep(1200,100);
              }
            break;
        default:
            break;
        }
}
haman
中階會員


發表:46
回覆:137
積分:56
註冊:2005-03-10

發送簡訊給我
#3 引用回覆 回覆 發表時間:2005-10-20 02:05:35 IP:211.76.xxx.xxx 未訂閱
void __fastcall TForm1::StringGridKeyPress(TObject *Sender, char &Key)
{            if(StringGrid->Row >= StringGrid->RowCount-1 && StringGrid->Col >= StringGrid->ColCount-1)
        {
                StringGrid->Cells[StringGrid->Col][StringGrid->Row]=StringGrid->Cells[StringGrid->Col][StringGrid->Row] Key;
                ShowMessage("資料已滿");
                return;
        }
        if(StringGrid->Cells[StringGrid->Col][StringGrid->Row].Length() == 2)
        {
                if(StringGrid->Col == StringGrid->ColCount-1)
                {
                        StringGrid->Row  ;
                        StringGrid->Col = 0;
                }
                else
                        StringGrid->Col  ;
        }
        StringGrid->Cells[StringGrid->Col][StringGrid->Row]=StringGrid->Cells[StringGrid->Col][StringGrid->Row] Key;
}
==================================== 懂的不多,卻想學的更多,搞得不自覺的將問題複雜化@@
haman
中階會員


發表:46
回覆:137
積分:56
註冊:2005-03-10

發送簡訊給我
#4 引用回覆 回覆 發表時間:2005-10-20 02:15:14 IP:211.76.xxx.xxx 未訂閱
另外,補充一下,如果要動態插入/刪除row的話可以參考 http://delphi.ktop.com.tw/topic.php?TOPIC_ID=78778 自行修改,新增的話直接RowCount 就行了 ==================================== 懂的不多,卻想學的更多,搞得不自覺的將問題複雜化@@
系統時間:2024-04-28 14:52:01
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!