ورود

نسخه کامل مشاهده نسخه کامل : تیک زدن در دی بی گرید



P A R M I S
19-10-2008, 19:57
با سلام
یه مشکلی که دارم اینکه یک دی بی گرید دارم که در اون هم اطلاعاتی مانند نام و فامیل و مانند اینها (به فارسی ) وجود داره و هم یک ستون دارم که برای حضور و غیاب این افراد در نظر گرفته ام برای تیک زدن چطور عمل کنم بهتره ؟ (از دلفی استفاده می کنم با بانک sql)
خودم از ستاره استفاده می کنم و بعد باید بگم افرادی که در فلان تاریخ حاضر بودند چند نفرند ؟ چون از خط فارسی در دی بی گرید استفاده می کنم موقع ریختن اطلاعات از علامت ستاره استفاده می کنم که اون رو بصورت ضرب نشون می ده نه ستاره و در جستجو ها علامت ستاره را که می زنم بصورت ستاره نشون می ده حالت زبان اون رو فارسی هم می کنم ولی بازهم بصورت ستاره نشون می ده نه ضربدر و جستجو که می کنم علامت ضربدر پیدا نمی کنه بنابراین چیزی رو در نتیجه نشون نمی ده لطفا کمک کنید
در عین حال اگه بخوام بصورت تیک دار باشه چطور می تونم و موقع جستجو چطوری علامت تیک رو جستجو کنم ؟
و آیا می شه یک ستون از دی بی گرید به فارسی باشه و یک ستون با فونتهای انگلیسی ؟ ممنون

F A R H A D
19-10-2008, 23:11
سلام. فیلد حضور و غیاب رو boolean انتخاب کنید و در grid بصورت check box نمایش بدید
پیشنهاد: شما در تمام پستهاتون فونت رو عوض کردید، یک بار هم از فونت استاندارد فروم استفاده کنید ضرر نداره! خوندنش برای ما خیلی ساده تر هست
موفق باشید

as13851365
20-10-2008, 09:53
نیازی به کاراکترهای * و غیره نیست شما به راحتی می تونید یک چک باکس رو در داخل دیبی گرید قرار بدید و ازش استفاده کنید

یک برنامه ای رو دوستان قبلا در انجمن به همراه سورس قرار داده بودن که یک چک باکس رو در داخل دیبی گرید قرار داده بود و با انتخاب اون می تونستید مقدار فیلد رو عوض کنید

اگر جستجو کنید حتما به نتیجه می رسید .

Hadi_0261
20-10-2008, 10:40
دوست عزیز . شما به جای DBgrid از CXgrid استفاده کنید . در این کامپونت میتونید برای هر فیلد یک نوع خاص تعریف کنید که شما باید گزینه CheckBox رو انتخاب کنید که شکل اون فیلد رو به صورت CheckBox در میاره . در ضمن شما در بانک SQL میتونید نوع فیلدتون رو از نوع Bit انتخاب کنید که فقط یک مقدار بگیره 0 یا 1 (true یا false) بعد تو برنامه تعریف کنید که اگه تیک چک زده شده بود = 0و در غیر این صورت 1 باشه. موفق باشید.

P A R M I S
20-10-2008, 11:08
سلام
و ممنون از پاسخ همه شما دوستان
ببخشید از اینکه خوندن این نوع فونت برای شماها راحت نبوده و در عین حال پاسخ سوالامو می دین تو تاپیک شما که خوندم اتفاقا تمام پستهای مربوط به تاپیک دلفی فرهاد رو هم خوندم ولی همچین چیزی پیدا نکردم و همچنین کلمات dbgrid و check box رو هم حتی جستجو کردم ولی نتیجه ای نگرفتم می شه مسیر مستقیمشو بگید ممنون
و شما هادی عزیز می شه بگید cxgrid تو کدوم تب و آیا طرز استفادش دقیقا مثل dbgrid یا نه ؟ از شما هم ممنونم

Hadi_0261
20-10-2008, 12:47
شما باید Dev Express رو نصب کنید که CXgrid یکی از کامپونت های این تبه . طرز کارش هم خیلی راحته . اگه Dev Express رو پیدا نکردی بگو تا برات بذارم هرچند که فکر میکنم تو همین سایت هم باشه .

P A R M I S
20-10-2008, 13:40
اگه می شه بذارید اگه بخوام دنبال بگردم تو این سایت گم می شم

F A R H A D
20-10-2008, 13:51
اتفاقا تمام پستهای مربوط به تاپیک دلفی فرهاد رو هم خوندم ولی همچین چیزی پیدا نکردم
اگر منظور شما تاپیک sql هست که صحبت در این زمینه، در اون تاپیک کاملا بی مورد هست!

به هر حال علاوه بر کامپوننت های آماده DevExpress که توسط NoneForce عزیز در همین بخش دلفی معرفی شده شما میتونید از کد زیر هم استفاده کنید. با این کد می تونید در کنترل DBGrid برای مقادیر منطقی به جای True یا False از CheckBox استفاده کنید

این کد یونیت :

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید

P A R M I S
20-10-2008, 17:22
سلام
آقا فرهاد و بقیه دوستان عزیز
آقا فرهاد این تکه برنامه ای رو که شما گذاشتید رو من تو فرم گذاشتم و می خوام ببینم چطوری فیلدهام به صورت CHECK BOX می شود
1- یعنی من باید تو جدولم (SQL) در فیلدهام t یا f قرار بدم و در برنامه دلفیم موقع اجرا خودش به صورت چک باکس نشون می ده یا نه به صورت دیگه ای باید عمل کنم
2- و هنگامی که من می خوام تو برنامم یک فیلدی رو چک باکس بزنم با چه دکمه ای باید اینکار رو انجام بدم
3- همچنین در یک دی بی گرید آیا می شه اطلاعات یک سطر رو به صورت غیر فعال درآورد که اجازه تغییر اطلاعات اون سطر وجود نداشته باشد ؟

F A R H A D
21-10-2008, 14:18
1- یعنی من باید تو جدولم (SQL) در فیلدهام t یا f قرار بدم و در برنامه دلفیم موقع اجرا خودش به صورت چک باکس نشون می ده یا نه به صورت دیگه ای باید عمل کنم
نوع فيلد رو bit بذاريد و با مقادير true و false يا 0 و 1 پركنيد، اين كد بقيه كارها رو انجام ميده

2- و هنگامی که من می خوام تو برنامم یک فیلدی رو چک باکس بزنم با چه دکمه ای باید اینکار رو انجام بدم
فقط كافيه از مقادير true و false استفاده كنيد

3- همچنین در یک دی بی گرید آیا می شه اطلاعات یک سطر رو به صورت غیر فعال درآورد که اجازه تغییر اطلاعات اون سطر وجود نداشته باشد ؟
تمام ركوردها رو ميشه read only كرد اما اگر فقط يك ركورد رو ميخوايد غير قابل دسترس كنيد بايد كدنويسي كنيد

P A R M I S
21-10-2008, 19:10
با سلام
من هم در جدولم یکی از ستونهام رو از نوع bit گذاشته ام و مقدار موجود در اون فیلد رو t یا f قرار داده ام و یک ستون دیگر هم دارم که در اون فیلد مقادیر 0 یا 1 قرار داده ام و برنامه شما رو هم در اون فرم قرار داده ام اما هنگام اجرا به صورت چک باکس نیست مشکل کجاست (دلفی با بانک sql ) یعنی همون t یا f نشون می ده و یا همون 0 یا 1 رو نشون می ده ممنون

F A R H A D
22-10-2008, 08:26
در صورت امكان يك سورس از برنامه رو اينجا بگذاريد تا بررسي بشه

P A R M I S
22-10-2008, 12:01
ببخشید سورس برنامه دقیقا همون چیزیه که خودتون در همین تاپیک در پست های قبلی گذاشتید می شه همون سورسی رو که خودتون گذاشتید در فرم های دلفی بذارید که انجام شدنی باشه

F A R H A D
22-10-2008, 12:58
پس بايد كمي صبور باشيد...

P A R M I S
24-10-2008, 18:42
ببخشید می شه بگید تا کی منتظر باشم ؟

F A R H A D
26-10-2008, 11:26
من كه گفتم بايد صبور باشيد!
بفرماييد:

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید

P A R M I S
26-10-2008, 12:16
با سلام به آقا فرهاد و ممنون از برنامه که گذاشته بودین می خواستم ببینم اولا شما از چه بانکی استفاده کردین چون من دارم از بانک sql استفاده می کنم و شما گفته بودین باید نوع اون ستونی که می خوایم به صورت چک باکس باشه باید از نوع boolean باشه می خواستم ببینم کجا باید نوعش رو boolean کنم چون در sql نوع boolean اصلا وجود نداره و ثانیا این قطعه برنامه رو اگه بخوام تغییر بدم مثلا تو جایی که گفته شده boolean من بذارم بعنوان مثال char و فقط همین ستون موردنظرم رو هم از نوع char بذارم درست می شه یا نه ؟ ممنون

F A R H A D
26-10-2008, 12:27
جدولي كه اينجا استفاده شده، يكي از نمونه هاي خود دلفي هست.
براي استفاده از boolean در sql server هم نوع فيلد رو bit بگذاريد.

P A R M I S
26-10-2008, 12:54
اون وقت دیگه در اون ستون که من نمی تونم true بنویسم چون فقط اجازه وارد کردن یک کاراکتر ندارم از t یا f یا 1و0 هم استفاده کردم ولی جواب نداد

F A R H A D
26-10-2008, 13:24
اون وقت دیگه در اون ستون که من نمی تونم true بنویسم چون فقط اجازه وارد کردن یک کاراکتر ندارم از t یا f یا 1و0 هم استفاده کردم ولی جواب نداد

مگه نوع داده اي فيلد رو bit نگذاشتيد؟ اگر اين كار رو كرديد true , false , 0 , 1 همگي جواب خواهند داد

kont_200
27-10-2008, 09:51
چرا این همه دردسر می دید خودتونو
از کامپوننت های tmssoftware استفاده کنید در غیر این صورت مطرح کنید تا من یک مثال براتون برای هر چی می خواهید بزارم

kont_200
27-10-2008, 10:03
یک فرم به نام فرم 80 هست تو یک پروژه add کننین و مثالشو ببینین اگر هم می خواین براتون prjecte شم بسازم

برای مشاهده محتوا ، لطفا وارد شوید یا ثبت نام کنید

kont_200
27-10-2008, 18:51
<div dir=ltr>
Problem/Question/Abstract:
How to put components into a cell on a TDBGrid

Answer:
This article and the accompanying code shows how to put just about any component into a cell on a grid. By component I mean anything from a simple combobox to a more complicated dialog box. The techniques described below to anything that is termed a visual component. If you can put it into a form you can probably put it into a grid.

There are no new ideas here, in fact, the basic technique simply mimics what the DBGrid does internally. The idea is to float a control over the grid. Inside DBGrid is a TDBEdit that moves around the grid. It's that TDBEdit that you key you data into. The rest of the unfocused cells are really just pictures. What you will learn here, is how to float any type of visual control/component around the grid.

1. TDBLookupComboBox:
You need a form with a DBGrid in it. So start an new project and drop a DBGrid into the main form.

Next drop in a TTable and set it's Alias to DBDEMOS, TableName to GRIDDATA.DB and set the Active property to True. Drop in a DataSource and set it's DataSet property to point to Table1. Go back to the grid and point it's DataSource property to DataSource1. The data from GRIDDATA.DB should appear in your grid.

The first control we are going to put into the grid is a TDBLookupComboBox so we need a second table for the lookup. Drop a second TTable into the form. Set it's Alias also to DBDEMOS, TableName to CUSTOMER.DB and Active to True. Drop in a second data source and set its DataSet to Table2.

Now go get a TDBLookupComboBox from the Data Controls pallet and drop it any where on the form, it doesn't matter where since it will usually be invisible or floating over the grid. Set the LookupComboBox's properties as follows.

DataSource: DataSource1
DataField: CustNo
LookupSource: DataSource2
LookupField: CustNo
LookupDisplay: CustNo {you can change it to Company later but keep it custno for now)

So far it's been nothing but boring point and click. Now let's do some coding.


The first thing you need to do is make sure that DBLookupComboBox you put into the form is invisible when you run the app. So select Form1 into Object Inspector goto the Events tab and double click on the onCreate event. You should now have the shell for the onCreate event displayed on your screen.

کد:
procedure TForm1.FormCreate(Sender: TObject);beginend;
Set the LookupComboBox's visible property to False as follows:

کد:
procedure TForm1.FormCreate(Sender: TObject);begin DBLookupCombo1.Visible := False;end;
Those of you who are paying attention are probably asking why I didn't just set this in the Object Inspector for the component. Actually, you could have. Personally, I like to initialize properties that change at run time in the code. I set static properties that don't change as the program runs in the object inspector. I think it makes the code easier to read.

Now we to be able to move this control around the grid. Specifically we want it to automatically appear as you either cursor or click into the column labeled DBLookupCombo. This involves defining two events for the grid, OnDrawDataCell and OnColExit. First lets do OnDrawDataCell. Double click on the grid's OnDrawDataCell event in the Object Inspector and fill in the code as follows.

کد:
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin if (gdFocused in State) then begin if (Field.FieldName = DBLookupCombo1.DataField) then begin DBLookupCombo1.Left := Rect.Left + DBGrid1.Left; DBLookupCombo1.Top := Rect.Top + DBGrid1.top; DBLookupCombo1.Width := Rect.Right - Rect.Left; { DBLookupCombo1.Height := Rect.Bottom - Rect.Top; } DBLookupCombo1.Visible := True; end; end;end;
The reasons for the excessive use begin/end will become clear later in the demo. The code is saying that if the State parameter is gdFocused then this particular cell is the one highlighted in the grid. Further if it's the highlighted cell and the cell has the same field name as the lookup combo's datafield then we need to move the LookupCombo over that cell and make it visible. Notice that the position is determined relative to the form not to just the grid. So, for example, the left side of LookupCombo needs to be the offset of the grid ( DBGrid1.Left) into the form plus the offset of the cell into the grid (Rect.Left).

Also notice that the Height of the LookupCombo has been commented out above. The reason is that the LookupCombo has a minimum height. You just can't make it any smaller. That minimum height is larger than the height of the cell. If you un-commented the height line above. Your code would change it and then Delphi would immediately change it right back. It causes an annoying screen flash so don't fight it. Let the LookupCombo be a little larger than the cell. It looks a little funny but it works.

Now just for fun run the program. Correct all you missing semi-colons etc. Once its running try moving the cursor around the grid. Pretty cool, hu? Not! We're only part of the way there. We need to hide the LookupCombo when we leave the column. So define the grid's onColExit. It should look like this:

کد:
procedure TForm1.DBGrid1ColExit(Sender: TObject);begin if DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then DBLookupCombo1.Visible := false;end;
This uses the TDBGrids SelectedField property to match up the FieldName associated with the cell with that of the LookupCombo. The code says, "If the cell you are leaving was in the DBLookupCombo column then make it invisible". Now run it again. Was that worth the effort or what?

Now things look right but we're still missing one thing. Try typing a new customer number into one of the LookupCombo. The problem is that the keystrokes are going to the grid, not to the LookupCombo. To fix this we need to define a onKeyPress event for the grid. It goes like this:
کد:
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);begin if (key &lt;> chr(9)) then begin if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then begin DBLookupCombo1.SetFocus; SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0); end; end;end;
This code is saying that if the key pressed is not a tab key (Chr(9)) and the current field in the grid is the LookupCombo then set the focus to the LookupCombo and then pass the keystroke over to the LookupCombo. OK so I had to use a WIN API function. You don't really need to know how it works just that it works.

But let me explain a bit anyway. To make Window's SendMessage function work you must give it the handle of the component you want to send the message to. Use the component's Handle property. Next it wants to know what the message is. In this case it's Window's message WM_CHAR which says I'm sending the LookupCombo a character. Finally, you need to tell it which character, so word(Key). That's a typecast to type word of the events Key parameter. Clear as mud, right? All you really need to know is to replace the DBLookupCombo1 in the call to the name of the component your putting into the grid. If you want more info on SendMessage do a search in Delphi's on-line help.

Now run it again and try typing. It works! Play with it a bit and see how the tab key gets you out of "edit mode" back into "move the cell cursor around mode".

Now go back to the Object Inspector for the DBLookupCombo component and change the LookupDIsplay property to Company. Run it. Imagine the possibilities.

2. TDBComboBox:
I'm not going to discuss installing the second component, a DBComboBox, because I don't really have anything new to say. It's really the same as #1. Here's the incrementally developed code for your review.

کد:
procedure TForm1.FormCreate(Sender: TObject);begin DBLookupCombo1.Visible := False; DBComboBox1.Visible := False;end;procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin if (gdFocused in State) then begin if (Field.FieldName = DBLookupCombo1.DataField) then begin DBLookupCombo1.Left := Rect.Left + DBGrid1.Left; DBLookupCombo1.Top := Rect.Top + DBGrid1.top; DBLookupCombo1.Width := Rect.Right - Rect.Left; DBLookupCombo1.Visible := True; end else if (Field.FieldName = DBComboBox1.DataField) then begin DBComboBox1.Left := Rect.Left + DBGrid1.Left; DBComboBox1.Top := Rect.Top + DBGrid1.top; DBComboBox1.Width := Rect.Right - Rect.Left; DBComboBox1.Visible := True; end; end;end;procedure TForm1.DBGrid1ColExit(Sender: TObject);begin if DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then DBLookupCombo1.Visible := false else if DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then DBComboBox1.Visible := false;end;procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);begin if (key &lt;> chr(9)) then begin if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then begin DBLookupCombo1.SetFocus; SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0); end else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField) then begin DBComboBox1.SetFocus; SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0); end; end;end;
3. TDBCheckBox:
The DBCheckBox gets even more interesting. In this case it seems appropriate to leave something in the non-focused checkbox cells to indicate that there's a check box there. You can either draw the "stay behind" image of the checkbox or you can blast in a picture of the checkbox. I chose to do the latter. I created two BMP files one that's a picture of the box checked (TRUE.BMP) and one that's a picture of the box unchecked (FALSE.BMP). Put two TImage components on the form called ImageTrue and ImageFalse and attach the BMP files to there respective Picture properties. Oh yes you also need to put a DBCheckbox component on the form. Wire it to the CheckBox field in DataSource1 and set the Color property to clWindow. First edit the onCreate so it reads as follows:

کد:
procedure TForm1.FormCreate(Sender: TObject);begin DBLookupCombo1.Visible := False; DBCheckBox1.Visible := False; DBComboBox1.Visible := False; ImageTrue.Visible := False; ImageFalse.Visible := False;end;
Now we need to modify the onDrawDataCell to do something with cells that do not have the focus. Here comes the code.

کد:
procedure TForm1.DBGrid1DrawDataCell(Sender: TObject; const Rect: TRect; Field: TField; State: TGridDrawState);begin if (gdFocused in State) then begin if (Field.FieldName = DBLookupCombo1.DataField) then begin {... see above} end else if (Field.FieldName = DBCheckBox1.DataField) then begin DBCheckBox1.Left := Rect.Left + DBGrid1.Left + 1; DBCheckBox1.Top := Rect.Top + DBGrid1.top + 1; DBCheckBox1.Width := Rect.Right - Rect.Left { - 1 }; DBCheckBox1.Height := Rect.Bottom - Rect.Top { - 1 }; DBCheckBox1.Visible := True; end else if (Field.FieldName = DBComboBox1.DataField) then begin {... see above} end; end else {in this else area draw any stay-behind bitmaps} begin if (Field.FieldName = DBCheckBox1.DataField) then begin if TableGridDataCheckBox.AsBoolean then DBGrid1.Canvas.Draw(Rect.Left, Rect.Top, ImageTrue.Picture.Bitmap) else DBGrid1.Canvas.Draw(Rect.Left, Rect.Top, ImageFalse.Picture.Bitmap) end; end;end;
It's the very last part we're most interested in. If the state is not gdFocused and the column in CheckBox then this last bit executes. All it does is check the value of the data in the field and if it's true it shows the TRUE.BMP otherwise it shows the FALSE.BMP. I created the bit maps so they are indented so you can tell the difference between a focused and unfocused cell. Make onColExit look like this:

کد:
procedure TForm1.DBGrid1ColExit(Sender: TObject);begin if DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField then DBLookupCombo1.Visible := false else if DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField then DBCheckBox1.Visible := false else if DBGrid1.SelectedField.FieldName = DBComboBox1.DataField then DBComboBox1.Visible := false;end;
Edit onKeyPress to:

کد:
procedure TForm1.DBGrid1KeyPress(Sender: TObject; var Key: Char);begin if (key &lt;> chr(9)) then begin if (DBGrid1.SelectedField.FieldName = DBLookupCombo1.DataField) then begin DBLookupCombo1.SetFocus; SendMessage(DBLookupCombo1.Handle, WM_Char, word(Key), 0); end else if (DBGrid1.SelectedField.FieldName = DBCheckBox1.DataField) then begin DBCheckBox1.SetFocus; SendMessage(DBCheckBox1.Handle, WM_Char, word(Key), 0); end else if (DBGrid1.SelectedField.FieldName = DBComboBox1.DataField) then begin DBComboBox1.SetFocus; SendMessage(DBComboBox1.Handle, WM_Char, word(Key), 0); end; end;end;
Finally, here's the last trick. The caption of the checkbox needs to change as the user checks or unchecks the box. My first thought was to do this in the TDBCheckBox's onChange event, the only problem is that it doesn't have one. So I had to go back to the Windows API and send another message. "SendMessage(DBCheckBox1.Handle, BM_GetCheck, 0, 0)" which returns a 0 if the box is unchecked, otherwise it's checked.

کد:
procedure TForm1.DBCheckBox1Click(Sender: TObject);begin if SendMessage(DBCheckBox1.Handle, BM_GetCheck, 0, 0) = 0 then DBCheckBox1.Caption := ' ' + 'False' else DBCheckBox1.Caption := ' ' + 'True'end;
That's it. Hopefully you learned something. I've tried this technique with dialog boxes. It works and it's simple. Have fun with it. You don't really need to completely understand it as long as you know how to edit the code and replace the above component names with with the name of the component you want to drop into the grid.

4. Enhancements and error correction:

There are 2 stichy points about the Original grid demo. First, once a component in the grid has the focus it takes 2 Tab presses to move to the next grid cell. The other has to do with adding new records.

Problem one - Two Tab Presses Required

A component installed in the grid is actually floating over the top of the grid and not part of the grid it self. So when that component has the focus it takes two tab presses to move to the next cell. The first tab moves from the floating component to the Grid cell underneath and the second to move to the next grid cell. If this behavior bugs you heres how to fix it.

First in the form that contains grid add private variable called WasInFloater of type boolean, like so.

کد:
type TForm1 = class(TForm) {...} private { Private declarations } WasInFloater: Boolean; {...} end;
Next create an onEnter event for the LookupCombo where WasInFloater is set to true. Then point the onEnter event for each component that goes into the grid at this same single onEnter event.

کد:
procedure TForm1.DBLookupCombo1Enter(Sender: TObject);begin WasInFloater := True;end;
Finally, and here's the tricky part, define the following onKeyUp event for the grid.

کد:
procedure TForm1.DBGrid1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);begin if (Key in [VK_TAB]) and WasInFloater then begin SendMessage(DBGrid1.Handle, WM_KeyDown, Key, 0); WasInFloater := False; end;end;
What's happening here is that the grid's onKeyUp is sending it self a KeyDown when the focus just switched from one of the floating controls. This solution handles both tab and shift-tab.

Problem two - New record disappears when component gets focus

The second problem is that if you press add record on the navigator in the demo a new record is added but then when you click on one of the components installed in the grid the new record disappears. The reason for this is that there is a strange grid option called dgCancelOnExit which is True by default. Set it to False and the above problem goes away.</div


با تشکر از دوست خوبم آقای مهدی کرامتی
تقدیم به دوستان خوبم

P A R M I S
27-10-2008, 20:37
آدرس پست 22 که باز نشد

kont_200
28-10-2008, 11:01
می بخشید با عجله بود
[ برای مشاهده لینک ، لطفا با نام کاربری خود وارد شوید یا ثبت نام کنید ] ([ برای مشاهده لینک ، لطفا با نام کاربری خود وارد شوید یا ثبت نام کنید ])

P A R M I S
08-11-2008, 16:03
بازم سلام به شما و آقا فرهاد
ببخشید آقا فرهاد در مورد برنامه ای که در پست 17 گذاشتید انجام شد ولی حالا مشکلم اینه که می خوام با توجه به اطلاعاتی که در یک جدول وجود داره و در دی بی گرید نشون داده می شه یک سری عملیاتی انجام بدم و با توجه به دی بی گرید بگم هر جا در دی بی گرید ( در فلان ستون ) تیک خورده بود نام این شخص را مثلا در edit1 بریزد
if DBGrid1.Columns.Items[2].Field.AsString='true' then
edit1.text:=DBGrid1.Columns.Items[0].Field.AsString;

F A R H A D
09-11-2008, 08:49
بازم سلام به شما و آقا فرهاد
ببخشید آقا فرهاد در مورد برنامه ای که در پست 17 گذاشتید انجام شد ولی حالا مشکلم اینه که می خوام با توجه به اطلاعاتی که در یک جدول وجود داره و در دی بی گرید نشون داده می شه یک سری عملیاتی انجام بدم و با توجه به دی بی گرید بگم هر جا در دی بی گرید ( در فلان ستون ) تیک خورده بود نام این شخص را مثلا در edit1 بریزد
if DBGrid1.Columns.Items[2].Field.AsString='true' then
edit1.text:=DBGrid1.Columns.Items[0].Field.AsString;

از كد زير استفاده كنيد:

if Table1.FieldValues['paid']=true then
Edit1.Text:=Table1.FieldValues['resno']
else
Edit1.Text:='not found';

P A R M I S
09-11-2008, 13:33
سلام آقا فرهاد از همین قطعه کد استفاده کردم با این تفاوت که به جای table1 از adoquery1 استفاده کردم اما همه ی فیلدها رو true درنظر می گیره و دستور مربوط به if را اجرا می کنه اما وارد else نمی شه (و این قطعه برنامه را در دی بی گرید در on cell click نوشتم )

F A R H A D
09-11-2008, 14:08
سلام آقا فرهاد از همین قطعه کد استفاده کردم با این تفاوت که به جای table1 از adoquery1 استفاده کردم اما همه ی فیلدها رو true درنظر می گیره و دستور مربوط به if را اجرا می کنه اما وارد else نمی شه (و این قطعه برنامه را در دی بی گرید در on cell click نوشتم )

در onCellClick نوشتم و تست كردم. جواب ميده
مشكل در جاي ديگه هست