Autor Beitrag
5M17H
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Do 28.09.06 19:50 
Hallo an alle.
In der Schule haben wir die Hausaufgabe bekommen ein Soduko Spiel zu Programmieren.
Wir haben 2 ArbeitsBlätter bekommen.

Um eine maske zu entwickeln, sollen wir bei Form1 das ereigniss onCreate nutzen.

Da sollen wir reinschreiben

ausblenden Delphi-Quelltext
1:
Stringgrid1.cells[0,0] := '4';					


usw.
Jetzt unterstreicht der bei mir Stringgrid1.cells[0,0] und sagt:
ausblenden Delphi-Quelltext
1:
E2003: Undefinierter Bezeichner: 'Stringgrid1'					


Das TStringGrid heißt : StringGrid1.
Warum sagt er, das sei falsch?

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}



procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (key in['0' .. '9', #8]) then
    key := #0;
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
  Stringgrid1.cells[0,0] := '4';
end;

end.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 28.09.06 19:52 
Es gibt auch kein StringGrid in deiner Form.

_________________
Markus Kinzler.
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Do 28.09.06 19:54 
Warum denn nicht, habe da doch eins.
Was muss ich denn machen um eins zu haben im code, auser im design?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 28.09.06 19:56 
Wenn es im Design ist, legt die IDE es normalerweise auch im Code an, in deinem Code fehlt die Deklaration aber.

_________________
Markus Kinzler.
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Do 28.09.06 19:58 
Gute info.....
Und wie mache ich die?

Hier auf meinen Arbeitsblättern steht ncihts, unser lehrer hat uns ncihts gesagt, er hatte während er uns das prog präsentiert hat das Soduko shcon fertig, also das programm.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 28.09.06 19:59 
Einfach die Komponente auf die Form ziehen.

_________________
Markus Kinzler.
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Do 28.09.06 20:00 
Tja, diene angaben sind Prezise.

Ich habe das StringGrid1 schon längst im form. Alles fertig!
Willste zum beweis, das der fehler nciht bei mir liegt ;-), ein screen haben?
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Do 28.09.06 20:02 
Dann entferne eben das jetzige Grid und ziehe ein neues auf die Form.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 28.09.06 20:02 
Dann hat dein Delphi einen Schuß.

_________________
Markus Kinzler.
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Do 28.09.06 20:17 
Danke jetzt gehts.
Jetzt eine frage zum layout.
Der 'Block' fürs Soduko ost ja 9*9 Felder.
Wie kann ich einstellen das er immer Einen dicken rahmen alle 3*3 felder macht?

Diese 9*9 Felder sind ja in der Übersicht getrennt in 3*3 felder mit jeweils 3*3 felder.
Ich hoffe ihr versteht was ich meine.

Ich will alle 3*3 felder den Rahmen anstatt auf 1 auf 2 haben doer so.

[edit]
Sone walhalla ey.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
  const Value: string);
var i : integer;
begin
  if value='' then
    exit;

  for i := acol +1 to 9 do
  begin
    if value = stringgrid1.cells[i,arow] then
    begin
      showmessage('Zahl gibt es schon');
      exit;
    end;
  end;
end;

So ists angeblich richtig.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
  const Value: string);
var i : integer;
begin
  if value='' then
    exit;

  for i := acol +1 to 9 do
  begin
    if value = stringgrid1.cells[1, arow] then
    begin
      showmessage('Zahl gibt es schon');
      exit;
    end;
  end;
end;

So war es vorher. Da war also bei [1, arow] nen fehler. er hat alles überprüft aber ab dem feld [1,0] nichtmehr.

Habe ich also in das obige code-element umgeändert.
Nunja, jetzt überprüft er nixmehr.
Warum wo ist da der Fehler?
uwewo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 154



BeitragVerfasst: Do 28.09.06 20:52 
[quote="user profile icon5M17H"]
Wie kann ich einstellen das er immer Einen dicken rahmen alle 3*3 felder macht?

[quote]

Suche Dir dazu hier im Forum und in der Online Hilfe mal

ausblenden Delphi-Quelltext
1:
2:
StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Fr 29.09.06 15:51 
Kann mir ncoh jemand zu meinem problem helfen?

[edit]

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
procedure TForm1.StringGrid1SetEditText(Sender: TObject; ACol, ARow: Integer;
  const Value: string);
var i : integer;
begin
  if value='' then
    exit;

  for i := acol +1 to 9 do
  begin
    if value = stringgrid1.cells[i,arow] then
    begin
      showmessage('Zahl gibt es schon');
      exit;
    end;
  end;

  for i := arow + 1 to 9 do
  begin
    if value = stringgrid1.cells[i,acol] then
    begin
      showmessage('Zahl gibt es schon');
      exit;
    end;
  end;
end;


Ohne spass, so siehts aus.
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Mo 02.10.06 00:16 
Will mir hier noch wer helfen?

Oder ist meine Problembeschreibung nur so assi?
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Mo 02.10.06 02:57 
was ist denn dein problem?
ich glaube nicht das es irgendjemanden besonders viel freude bereitet bei deinem code ein problem zufinden, und dann auch noch genau das problem, dass du meinst...
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Mo 02.10.06 07:32 
ausblenden 5M17H
1:
2:
3:
4:
5:
So war es vorher. Da war also bei [1, arow] nen fehler. er hat alles überprüft aber ab dem feld [1,0] nichtmehr.

Habe ich also in das obige code-element umgeändert.
Nunja, jetzt überprüft er nixmehr.
Warum wo ist da der Fehler?


Das habe ich schon geschrieben gehabt.

Mein Problem ist folgendes:
HA aus der schule eine sudoku zu programmieren.
Mache ich.
Jetzt haben wir nen ArbeitsBlatt. Da habe ich -nachdems bei mir nicht geklappt hat- alles abgeschrieben. Naja und jetzt gehts immernoch nciht.

Ich habe schon x varianten ausprobiert.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 02.10.06 09:27 
Wie groß ist das Grid ich vermute mal 9x9 dann sind die Maxima 9.9

ausblenden Delphi-Quelltext
1:
for i := acol +1 to 8 do					


ausblenden Delphi-Quelltext
1:
for i := arow +1 to 8 do					


ausblenden Delphi-Quelltext
1:
if value = stringgrid1.cells[i,acol] then					


muß

ausblenden Delphi-Quelltext
1:
if value = stringgrid1.cells[acol, i] then					

heißen

_________________
Markus Kinzler.
5M17H Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164

XP, Vista32, bald auch Vista64
PHP(3/5), Delphi(2), Java(1), C(3), C#(1)
BeitragVerfasst: Di 10.10.06 11:59 
Auflösung:
Ich habe -mal wieder- nen absoluten Anfängerproblem gehabt.
Auf die idee kommen, das er da NUR RECHTS nachschaut komm ich natürlich erst nachdem der lehrer meinte: so jetzt habt ihr die zeile nach rechts untersucht.

Natürlich brauchtman den codeabschnitt 4 mal.



Weis wer wie ich das quadrat überprüfe?
Also case acol of...... und so lege ich eben die quadranten fest. Aber ich muss ja nen vergleich aufstellen.

NAch 2std habe ich verzweifelt und aus zeitnot aufgeegeben.